2023-02-16 04:27:26 +08:00
|
|
|
// Environment file for getting variables
|
|
|
|
// Currently the only thing it does is set the master password
|
|
|
|
// Should probably have it take over functions from OS such as port and mongodb connection details
|
|
|
|
// Reads from the config/environments/dev.yaml file by default
|
2021-09-07 03:30:39 +08:00
|
|
|
package config
|
|
|
|
|
2022-03-19 03:06:48 +08:00
|
|
|
import (
|
|
|
|
"reflect"
|
|
|
|
"testing"
|
|
|
|
)
|
2021-09-07 03:30:39 +08:00
|
|
|
|
2022-03-19 03:06:48 +08:00
|
|
|
func Test_readConfig(t *testing.T) {
|
|
|
|
tests := []struct {
|
|
|
|
name string
|
|
|
|
want *EnvironmentConfig
|
|
|
|
wantErr bool
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
"ensure development config parses",
|
|
|
|
&EnvironmentConfig{},
|
|
|
|
false,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
2022-03-23 05:22:34 +08:00
|
|
|
got, err := ReadConfig("")
|
2022-03-19 03:06:48 +08:00
|
|
|
if (err != nil) != tt.wantErr {
|
|
|
|
t.Errorf("readConfig() error = %v, wantErr %v", err, tt.wantErr)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if !reflect.DeepEqual(got, tt.want) {
|
|
|
|
t.Errorf("readConfig() = %v, want %v", got, tt.want)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
2021-09-07 03:30:39 +08:00
|
|
|
}
|