mirror of
https://github.com/Luzifer/git-credential-vault.git
synced 2024-11-14 00:52:47 +00:00
32 lines
654 B
Go
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")
|
|
}
|
|
}
|