Skip to content
This repository has been archived by the owner on May 16, 2021. It is now read-only.

Commit

Permalink
tests: add test for config file
Browse files Browse the repository at this point in the history
  • Loading branch information
mainawycliffe committed Feb 10, 2020
1 parent bde6231 commit 9613b31
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions configs/viper_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package configs

import (
"testing"

"github.com/spf13/viper"
)

func TestUnsetViperConfig(t *testing.T) {
viper.SetConfigFile("./../testdata/.viper.yaml")
keys := []string{"key1", "key2", "key3", "key4", "key5"}
for _, v := range keys {
viper.Set(v, v)
}
type args struct {
keys []string
}
tests := []struct {
name string
args args
wantErr bool
}{
{"Test Case", args{keys: keys}, false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if err := UnsetViperConfig(tt.args.keys...); (err != nil) != tt.wantErr {
t.Errorf("UnsetViperConfig() error = %v, wantErr %v", err, tt.wantErr)
}
for _, v := range keys {
if viper.GetString(v) != "" {
t.Errorf("UnsetViperConfig() Expected viper key %s to be empty", v)
}
}
})
}
}

0 comments on commit 9613b31

Please sign in to comment.