No longer need to test old encoding

This commit is contained in:
Asim 2016-05-22 18:41:06 +01:00
parent 06ee80fd0a
commit 2708f9c04b

View File

@ -57,8 +57,8 @@ func TestEncodingEndpoints(t *testing.T) {
e := encodeEndpoints([]*Endpoint{ep}) e := encodeEndpoints([]*Endpoint{ep})
// check there are two tags; old and new // check there are two tags; old and new
if len(e) != 2 { if len(e) != 1 {
t.Fatalf("Expected 2 encoded tags, got %v", e) t.Fatalf("Expected 1 encoded tags, got %v", e)
} }
// check old encoding // check old encoding
@ -104,30 +104,24 @@ func TestEncodingEndpoints(t *testing.T) {
// HEX encoded // HEX encoded
hencoded := encode(jencoded) hencoded := encode(jencoded)
// endpoint tag // endpoint tag
jepTag := "e=" + string(jencoded)
hepTag := "e-" + hencoded hepTag := "e-" + hencoded
// test old
testEp(ep, jepTag)
// test new
testEp(ep, hepTag) testEp(ep, hepTag)
} }
} }
func TestEncodingVersion(t *testing.T) { func TestEncodingVersion(t *testing.T) {
testData := []struct { testData := []struct {
decoded string decoded string
encoded string encoded string
oldEncoded string
}{ }{
{"1.0.0", "v-789c32d433d03300040000ffff02ce00ee", "v=1.0.0"}, {"1.0.0", "v-789c32d433d03300040000ffff02ce00ee"},
{"latest", "v-789cca492c492d2e01040000ffff08cc028e", "v=latest"}, {"latest", "v-789cca492c492d2e01040000ffff08cc028e"},
} }
for _, data := range testData { for _, data := range testData {
e := encodeVersion(data.decoded) e := encodeVersion(data.decoded)
if e[1] != data.encoded { if e[0] != data.encoded {
t.Fatalf("Expected %s got %s", data.encoded, e) t.Fatalf("Expected %s got %s", data.encoded, e)
} }
@ -148,14 +142,5 @@ func TestEncodingVersion(t *testing.T) {
if d != data.decoded { if d != data.decoded {
t.Fatalf("Expected %s got %s", data.decoded, d) t.Fatalf("Expected %s got %s", data.decoded, d)
} }
d, ok = decodeVersion([]string{data.oldEncoded})
if !ok {
t.Fatalf("Unexpected %t for %s", ok, data.oldEncoded)
}
if d != data.decoded {
t.Fatalf("Expected %s got %s", data.decoded, d)
}
} }
} }