Skip to content

Commit

Permalink
fix unit test (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
JunNishimura committed Sep 1, 2023
1 parent b4798f6 commit da83157
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ func TestConfKey_isTokenKey(t *testing.T) {
},
want: false,
},
{
name: "false; port",
fields: fields{
confkey: PortKey,
},
want: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down Expand Up @@ -136,6 +143,13 @@ func TestConfKey_isClientKey(t *testing.T) {
},
want: true,
},
{
name: "true; port",
fields: fields{
confkey: PortKey,
},
want: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down Expand Up @@ -273,6 +287,16 @@ func TestConfig_Set(t *testing.T) {
wantValue: "test",
wantErr: false,
},
{
name: "success; port",
args: args{
key: PortKey,
value: "test",
},
wantKey: PortKey,
wantValue: "test",
wantErr: false,
},
{
name: "success; access token",
args: args{
Expand Down Expand Up @@ -347,6 +371,7 @@ func TestConfig_IsClientValid(t *testing.T) {
spotifySecret string
openAIapiKey string
deviceID string
port string
want bool
}{
{
Expand All @@ -355,6 +380,7 @@ func TestConfig_IsClientValid(t *testing.T) {
spotifySecret: "test",
openAIapiKey: "test",
deviceID: "test",
port: "test",
want: true,
},
{
Expand All @@ -363,6 +389,7 @@ func TestConfig_IsClientValid(t *testing.T) {
spotifySecret: "",
openAIapiKey: "",
deviceID: "",
port: "",
want: false,
},
}
Expand All @@ -387,6 +414,7 @@ func TestConfig_IsClientValid(t *testing.T) {
conf.clientViper.Set(string(SpotifySecretKey), tt.spotifySecret)
conf.clientViper.Set(string(OpenAIAPIKey), tt.openAIapiKey)
conf.clientViper.Set(string(DeviceID), tt.deviceID)
conf.clientViper.Set(string(PortKey), tt.port)

if conf.IsClientValid() != tt.want {
t.Errorf("got: %v, want: %v", conf.IsClientValid(), tt.want)
Expand Down

0 comments on commit da83157

Please sign in to comment.