1
0
Fork 0
mirror of https://github.com/Luzifer/git-credential-vault.git synced 2024-11-09 23:00:13 +00:00
git-credential-vault/main_test.go
Knut Ahlers 0ec1f62a58
Initial version
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2020-04-01 14:19:29 +02:00

32 lines
654 B
Go

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")
}
}