Skip to content

Commit 262db37

Browse files
authored
test(bigtable): fix MV tests (googleapis#12238)
1 parent 8e7d0b7 commit 262db37

File tree

1 file changed

+25
-17
lines changed

1 file changed

+25
-17
lines changed

bigtable/integration_test.go

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5002,20 +5002,24 @@ func TestIntegration_DataMaterializedView(t *testing.T) {
50025002
if err != nil {
50035003
t.Fatalf("Reading row from a materialized view: %v", err)
50045004
}
5005+
50055006
wantRow := Row{
50065007
"result": []ReadItem{
5007-
{Row: "r1", Column: "result:count", Timestamp: 1000, Value: []byte("1")},
5008+
{Row: "r1", Column: "result:count", Timestamp: 0, Value: binary.BigEndian.AppendUint64([]byte{}, 1)},
5009+
},
5010+
"default": []ReadItem{
5011+
{Row: "r1", Column: "default:", Timestamp: 0},
50085012
},
50095013
}
50105014
if !testutil.Equal(gotRow, wantRow) {
5011-
t.Fatalf("Error reading row from materialized view.\n Got %v\n Want %v", gotRow, wantRow)
5015+
t.Errorf("Error reading row from materialized view.\n Got %#v\n Want %#v", gotRow, wantRow)
50125016
}
50135017
gotRow, err = mv.ReadRow(ctx, "r2")
50145018
if err != nil {
50155019
t.Fatalf("Reading row from an materialized view: %v", err)
50165020
}
50175021
if len(gotRow) != 0 {
5018-
t.Fatalf("Expect empty result when reading row from outside an materialized view")
5022+
t.Errorf("Expect empty result when reading row from outside an materialized view")
50195023
}
50205024

50215025
// Test ReadRows
@@ -5031,14 +5035,14 @@ func TestIntegration_DataMaterializedView(t *testing.T) {
50315035
if err = mv.ReadRows(ctx, RowRange{}, f); err != nil {
50325036
t.Fatalf("Reading rows from an materialized view: %v", err)
50335037
}
5034-
want := "r1-col1-1"
5038+
want := "r1--,r1-count-" + string(binary.BigEndian.AppendUint64([]byte{}, 1))
50355039
if got := strings.Join(elt, ","); got != want {
5036-
t.Fatalf("Error bulk reading from materialized view.\n Got %v\n Want %v", got, want)
5040+
t.Errorf("Error bulk reading from materialized view.\n Got %q\n Want %q", got, want)
50375041
}
50385042

50395043
// Test SampleRowKeys
50405044
if _, err := mv.SampleRowKeys(ctx); err != nil {
5041-
t.Fatalf("Sampling row keys from an materialized view: %v", err)
5045+
t.Errorf("Sampling row keys from an materialized view: %v", err)
50425046
}
50435047
}
50445048

@@ -5214,14 +5218,16 @@ func TestIntegration_AdminMaterializedView(t *testing.T) {
52145218
if err != nil {
52155219
t.Fatalf("Listing materialized views: %v", err)
52165220
}
5217-
if got, want := len(materializedViews), 1; got != want {
5218-
t.Fatalf("Listing materialized views count: %d, want: != %d", got, want)
5221+
if got, want := len(materializedViews), 1; got < want {
5222+
t.Fatalf("Listing materialized views count: %d, want: >= %d", got, want)
52195223
}
5220-
if got, want := materializedViews[0].MaterializedViewID, materializedView; got != want {
5221-
t.Errorf("MaterializedView Name: %s, want: %s", got, want)
5222-
}
5223-
if got, want := materializedViews[0].Query, materializedViewInfo.Query; got != want {
5224-
t.Errorf("MaterializedView Query: %q, want: %q", got, want)
5224+
5225+
for _, mv := range materializedViews {
5226+
if mv.MaterializedViewID == materializedView {
5227+
if got, want := mv.Query, materializedViewInfo.Query; got != want {
5228+
t.Errorf("MaterializedView Query: %q, want: %q", got, want)
5229+
}
5230+
}
52255231
}
52265232

52275233
// Get materialized view
@@ -5258,8 +5264,8 @@ func TestIntegration_AdminMaterializedView(t *testing.T) {
52585264
t.Errorf("MaterializedViewInfo deletion protection: %v, want: %v", got, want)
52595265
}
52605266
// Check that the subset_view field doesn't change
5261-
if got, want := mvInfo.Query, materializedViewInfo.Query; cmp.Equal(got, want) {
5262-
t.Errorf("Query: %v, want: %v", got, want)
5267+
if got, want := mvInfo.Query, materializedViewInfo.Query; !cmp.Equal(got, want) {
5268+
t.Errorf("Query: %q, want: %q", got, want)
52635269
}
52645270

52655271
// Delete materialized view
@@ -5272,8 +5278,10 @@ func TestIntegration_AdminMaterializedView(t *testing.T) {
52725278
if err != nil {
52735279
t.Fatalf("Listing materialized views: %v", err)
52745280
}
5275-
if got, want := len(materializedViews), 0; got != want {
5276-
t.Fatalf("Listing materialized views count: %d, want: != %d", got, want)
5281+
for _, mv := range materializedViews {
5282+
if mv.MaterializedViewID == materializedView {
5283+
t.Errorf("Found view %q that was meant to be deleted", materializedView)
5284+
}
52775285
}
52785286
}
52795287

0 commit comments

Comments
 (0)