Skip to content

Commit

Permalink
add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nkvuong committed Feb 20, 2023
1 parent a7f7f47 commit 0216eb7
Showing 1 changed file with 30 additions and 4 deletions.
34 changes: 30 additions & 4 deletions catalog/resource_share_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,21 @@ func TestDiffShareInfo(t *testing.T) {
},
},
}
fourthShare := ShareInfo{
Name: "d",
Objects: []SharedDataObject{
{
Name: "main.b",
DataObjectType: "TABLE",
Comment: "d",
},
{
Name: "main.a",
DataObjectType: "TABLE",
Comment: "c",
},
},
}
diffAdd := []ShareDataChange{
{
Action: ShareAdd,
Expand Down Expand Up @@ -95,7 +110,7 @@ func TestDiffShareInfo(t *testing.T) {
},
},
}
diffMix := []ShareDataChange{
diff12 := []ShareDataChange{
{
Action: ShareRemove,
DataObject: SharedDataObject{
Expand All @@ -113,7 +128,7 @@ func TestDiffShareInfo(t *testing.T) {
},
},
}
diffMix2 := []ShareDataChange{
diff13 := []ShareDataChange{
{
Action: ShareRemove,
DataObject: SharedDataObject{
Expand All @@ -139,11 +154,22 @@ func TestDiffShareInfo(t *testing.T) {
},
},
}
diff14 := []ShareDataChange{
{
Action: ShareUpdate,
DataObject: SharedDataObject{
Name: "main.b",
DataObjectType: "TABLE",
Comment: "d",
},
},
}
assert.Equal(t, firstShare.Diff(firstShare), []ShareDataChange{}, "Should not have difference")
assert.Equal(t, empty.Diff(firstShare), diffAdd, "Should have 2 ADDs")
assert.Equal(t, firstShare.Diff(empty), diffRemove, "Should have 2 REMOVEs")
assert.Equal(t, firstShare.Diff(secondShare), diffMix, "Should have 1 ADD and 1 REMOVE")
assert.Equal(t, firstShare.Diff(thirdShare), diffMix2, "Should have 1 ADD, 1 REMOVE and 1 UPDATE")
assert.Equal(t, firstShare.Diff(secondShare), diff12, "Should have 1 ADD and 1 REMOVE")
assert.Equal(t, firstShare.Diff(thirdShare), diff13, "Should have 1 ADD, 1 REMOVE and 1 UPDATE")
assert.Equal(t, firstShare.Diff(fourthShare), diff14, "Should have 1 UPDATE")
}

func TestShareCornerCases(t *testing.T) {
Expand Down

0 comments on commit 0216eb7

Please sign in to comment.