-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ffe37a4
commit d1b1942
Showing
5 changed files
with
138 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
package main | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
//nolint:paralleltest // disabled | ||
func TestValidateConfigNoConfigProvided(t *testing.T) { | ||
defer func() { | ||
if r := recover(); r == nil { | ||
require.Fail(t, "Expected to have a panic here!") | ||
} | ||
}() | ||
|
||
os.Args = []string{"cmd", "validate-config"} | ||
main() | ||
assert.True(t, true) | ||
} | ||
|
||
//nolint:paralleltest // disabled | ||
func TestValidateConfigFailedToLoad(t *testing.T) { | ||
defer func() { | ||
if r := recover(); r == nil { | ||
require.Fail(t, "Expected to have a panic here!") | ||
} | ||
}() | ||
|
||
os.Args = []string{"cmd", "validate-config", "--config", "../assets/config-not-found.toml"} | ||
main() | ||
assert.True(t, true) | ||
} | ||
|
||
//nolint:paralleltest // disabled | ||
func TestValidateConfigInvalid(t *testing.T) { | ||
defer func() { | ||
if r := recover(); r == nil { | ||
require.Fail(t, "Expected to have a panic here!") | ||
} | ||
}() | ||
|
||
os.Args = []string{"cmd", "validate-config", "--config", "../assets/invalid-timezone.toml"} | ||
main() | ||
assert.True(t, true) | ||
} | ||
|
||
//nolint:paralleltest // disabled | ||
func TestValidateConfigWithWarnings(t *testing.T) { | ||
os.Args = []string{"cmd", "validate-config", "--config", "../assets/valid-unused-chain.toml"} | ||
main() | ||
assert.True(t, true) | ||
} | ||
|
||
//nolint:paralleltest // disabled | ||
func TestValidateConfigValid(t *testing.T) { | ||
os.Args = []string{"cmd", "validate-config", "--config", "../assets/valid.toml"} | ||
main() | ||
assert.True(t, true) | ||
} | ||
|
||
//nolint:paralleltest // disabled | ||
func TestStartNoConfigProvided(t *testing.T) { | ||
defer func() { | ||
if r := recover(); r == nil { | ||
require.Fail(t, "Expected to have a panic here!") | ||
} | ||
}() | ||
|
||
os.Args = []string{"cmd"} | ||
main() | ||
assert.True(t, true) | ||
} | ||
|
||
//nolint:paralleltest // disabled | ||
func TestStartConfigProvided(t *testing.T) { | ||
defer func() { | ||
if r := recover(); r == nil { | ||
require.Fail(t, "Expected to have a panic here!") | ||
} | ||
}() | ||
|
||
os.Args = []string{"cmd", "--config", "../assets/invalid-timezone.toml"} | ||
main() | ||
assert.True(t, true) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package fs | ||
|
||
import "os" | ||
|
||
type OsFS struct { | ||
} | ||
|
||
func (fs *OsFS) ReadFile(name string) ([]byte, error) { | ||
return os.ReadFile(name) | ||
} | ||
|
||
func (fs *OsFS) Create(path string) (File, error) { | ||
return os.Create(path) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package fs | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestOsFsCreate(t *testing.T) { | ||
t.Parallel() | ||
|
||
fs := &OsFS{} | ||
_, err := fs.Create("/tmp/file.txt") | ||
require.NoError(t, err) | ||
} |