1
0
mirror of https://github.com/Luzifer/git-credential-vault.git synced 2024-09-19 08:02:57 +00:00
git-credential-vault/main_test.go

33 lines
654 B
Go
Raw Normal View History

package main
import (
"strings"
"testing"
)
func TestReadInput(t *testing.T) {
input := strings.NewReader(strings.Join([]string{
"protocol=https",
"host=github.com",
"", // Defined as end-of-input
"shouldnt=bethere",
}, "\n"))
vars, err := readInput(input)
if err != nil {
t.Fatalf("Read input errored: %s", err)
}
if l := len(vars); l != 2 {
t.Errorf("Unexpected number of values: %d != 2", l)
}
if h := vars["host"]; h != "github.com" {
t.Errorf("Unexpected value %s: %s != %s", "host", h, "github.com")
}
if p := vars["protocol"]; p != "https" {
t.Errorf("Unexpected value %s: %s != %s", "protocol", p, "https")
}
}