Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add integration tests with skip lists for failing tests #33

Merged
merged 12 commits into from
May 29, 2020
32 changes: 7 additions & 25 deletions ion/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,19 +346,10 @@ func testBinaryRoundTrip(t *testing.T, fp string) {
// Re-encode binWriter's stream as text into a string builder
str := encodeAsTextIon(t, buf.String())

reader1 := NewReader(bytes.NewReader(buf.Bytes()))
reader2 := NewReader(strings.NewReader(str.String()))

for reader1.Next() {
i1 := readCurrentValue(t, reader1)
reader2.Next()
i2 := readCurrentValue(t, reader2)

if !reflect.DeepEqual(i1.value, i2.value) ||
!reflect.DeepEqual(i1.annotations, i2.annotations) ||
!reflect.DeepEqual(i1.ionType, i2.ionType) {
t.Errorf("failed %s %v vs %v", fp, i1.value, i2.value)
}
buf2 := encodeAsBinaryIon(t, []byte(str.String()))

if !reflect.DeepEqual(buf, buf2) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want to compare the buffers or strings that are produced directly; the encoded bytes can be different but still contain equivalent values. For example, the TextWriter and the PrettyTextWriter will produce different strings, but the values in the strings should be considered the same. Similarly, some data types like Timestamp have a variety of ways to encode the same value; 2007-02-23T00:00Z and 2007-02-23T00:00+00:00 are equivalent despite being encoded differently.

Copy link
Contributor Author

@R-maan R-maan May 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was hoping you read the email I sent about this before seeing it in the PR :P
Updated the test as talked offline.

t.Errorf("Round trip test failed on: " + fp)
}
}

Expand All @@ -373,19 +364,10 @@ func testTextRoundTrip(t *testing.T, fp string) {
// Re-encode txtWriter's stream as binary into a bytes.Buffer
buf := encodeAsBinaryIon(t, []byte(str.String()))

reader1 := NewReader(strings.NewReader(str.String()))
reader2 := NewReader(bytes.NewReader(buf.Bytes()))
str2 := encodeAsTextIon(t, buf.String())

for reader1.Next() {
i1 := readCurrentValue(t, reader1)
reader2.Next()
i2 := readCurrentValue(t, reader2)

if !reflect.DeepEqual(i1.value, i2.value) ||
!reflect.DeepEqual(i1.annotations, i2.annotations) ||
!reflect.DeepEqual(i1.ionType, i2.ionType) {
t.Errorf("failed %s %v vs %v", fp, i1.value, i2.value)
}
if !reflect.DeepEqual(str, str2) {
t.Errorf("Round trip test failed on: " + fp)
}
}

Expand Down