mirror of
https://github.com/aykhans/dodo.git
synced 2025-09-05 10:43:37 +00:00
Add 'ParseString' to the utils. Refactor enums of the 'ConfigFile'.
This commit is contained in:
@@ -6,39 +6,19 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
type ConfigFileType int
|
||||
type ConfigFileType string
|
||||
|
||||
const (
|
||||
ConfigFileTypeYAML ConfigFileType = iota
|
||||
ConfigFileTypeYAML ConfigFileType = "yaml/yml"
|
||||
)
|
||||
|
||||
func (t ConfigFileType) String() string {
|
||||
switch t {
|
||||
case ConfigFileTypeYAML:
|
||||
return "yaml/yml"
|
||||
default:
|
||||
return "unknown"
|
||||
}
|
||||
}
|
||||
|
||||
type ConfigFileLocationType int
|
||||
type ConfigFileLocationType string
|
||||
|
||||
const (
|
||||
ConfigFileLocationLocal ConfigFileLocationType = iota
|
||||
ConfigFileLocationRemote
|
||||
ConfigFileLocationLocal ConfigFileLocationType = "local"
|
||||
ConfigFileLocationRemote ConfigFileLocationType = "remote"
|
||||
)
|
||||
|
||||
func (l ConfigFileLocationType) String() string {
|
||||
switch l {
|
||||
case ConfigFileLocationLocal:
|
||||
return "local"
|
||||
case ConfigFileLocationRemote:
|
||||
return "remote"
|
||||
default:
|
||||
return "unknown"
|
||||
}
|
||||
}
|
||||
|
||||
type ConfigFile struct {
|
||||
path string
|
||||
_type ConfigFileType
|
||||
|
@@ -7,35 +7,6 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestConfigFileType_String(t *testing.T) {
|
||||
t.Run("ConfigFileTypeYAML returns yaml", func(t *testing.T) {
|
||||
configType := ConfigFileTypeYAML
|
||||
assert.Equal(t, "yaml/yml", configType.String())
|
||||
})
|
||||
|
||||
t.Run("Unknown config file type returns unknown", func(t *testing.T) {
|
||||
configType := ConfigFileType(999)
|
||||
assert.Equal(t, "unknown", configType.String())
|
||||
})
|
||||
}
|
||||
|
||||
func TestConfigFileLocationType_String(t *testing.T) {
|
||||
t.Run("ConfigFileLocationLocal returns local", func(t *testing.T) {
|
||||
locationType := ConfigFileLocationLocal
|
||||
assert.Equal(t, "local", locationType.String())
|
||||
})
|
||||
|
||||
t.Run("ConfigFileLocationRemote returns remote", func(t *testing.T) {
|
||||
locationType := ConfigFileLocationRemote
|
||||
assert.Equal(t, "remote", locationType.String())
|
||||
})
|
||||
|
||||
t.Run("Unknown location type returns unknown", func(t *testing.T) {
|
||||
locationType := ConfigFileLocationType(999)
|
||||
assert.Equal(t, "unknown", locationType.String())
|
||||
})
|
||||
}
|
||||
|
||||
func TestConfigFile_String(t *testing.T) {
|
||||
t.Run("String returns the file path", func(t *testing.T) {
|
||||
configFile := ConfigFile{path: "/path/to/config.yaml"}
|
||||
|
Reference in New Issue
Block a user