Skip to content

Commit

Permalink
[test/util] Add ReadConf tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mpsonntag committed Mar 19, 2021
1 parent c3cd7c9 commit d8b0b04
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions libgin/util_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,38 @@
package libgin

import (
"os"
"testing"
)

func Test_ReadConfDefault(t *testing.T) {
oskey := "test"
val := "tmp"
defval := "default"

testval := ReadConfDefault(oskey, defval)
if testval != defval {
t.Fatalf("Expected default value %q but got %q", defval, testval)
}

os.Setenv(oskey, val)
testval = ReadConfDefault(oskey, defval)
if testval != val {
t.Fatalf("Expected default value %q but got %q", val, testval)
}
}

func Test_ReadConf(t *testing.T) {
oskey := "test"
val := "tmp"
os.Setenv(oskey, val)

testval := ReadConf(oskey)
if val != testval {
t.Fatal("Could not read environment variable")
}
}

func Test_GetArchiveSize(t *testing.T) {
// URL is earliest archive with the new name format, so wont change.
// Older archives might be renamed to the new format soon.
Expand Down

0 comments on commit d8b0b04

Please sign in to comment.