package protocol import ( "net/http" "testing" ) func TestCompat(t *testing.T) { cases := []struct { bg, bgMin, bk, bkMin int want string }{ {1, 1, 1, 1, CompatOK}, {2, 1, 1, 1, CompatOK}, {1, 1, 2, 1, CompatOK}, {3, 2, 1, 1, CompatBackupTooOld}, {1, 1, 3, 2, CompatBlueGitTooOld}, } for _, c := range cases { if got := Compat(c.bg, c.bgMin, c.bk, c.bkMin); got != c.want { t.Errorf("Compat(%d,%d,%d,%d) = %s, wil %s", c.bg, c.bgMin, c.bk, c.bkMin, got, c.want) } } } func TestBlueGitFromHeader(t *testing.T) { if p, ok := BlueGitFromHeader(http.Header{}); ok || p.Protocol != 1 || p.MinProtocol != 1 { t.Fatalf("zonder koppen: %+v", p) } h := http.Header{} h.Set(HeaderBlueGitProtocol, "4") h.Set(HeaderBlueGitMinProtocol, "3") h.Set(HeaderBlueGitVersion, "abc