Skip to content

Commit

Permalink
Fix expected result set of transform test
Browse files Browse the repository at this point in the history
  • Loading branch information
keiko713 committed Nov 26, 2024
1 parent c737b95 commit 61e0193
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions output/transform/transform_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func TestStatements(t *testing.T) {
actual := transform.StateToSnapshot(newState, diffState, transientState)
actualJSON, _ := json.Marshal(actual)

// Query: 0, 1, Plan: 0, 1
// Query: 0, 1, Plan: 0, 1 (w/ QueryIdx 1)
expected := pganalyze_collector.FullSnapshot{
Config: &pganalyze_collector.CollectorConfig{},
CollectorStatistic: &pganalyze_collector.CollectorStatistic{},
Expand Down Expand Up @@ -134,7 +134,7 @@ func TestStatements(t *testing.T) {
}
expectedJSON, _ := json.Marshal(expected)

// Query: 1, 0, Plan: 0, 1
// Query: 1, 0, Plan: 0, 1 (w/ QueryIdx 0)
var expectedAlt pganalyze_collector.FullSnapshot
json.Unmarshal(expectedJSON, &expectedAlt)
expectedAlt.QueryReferences = []*pganalyze_collector.QueryReference{
Expand Down Expand Up @@ -171,16 +171,26 @@ func TestStatements(t *testing.T) {
Calls: 1,
},
}
expectedAlt.QueryPlanReferences = []*pganalyze_collector.QueryPlanReference{
&pganalyze_collector.QueryPlanReference{
QueryIdx: 0,
OriginalPlanId: 111,
},
&pganalyze_collector.QueryPlanReference{
QueryIdx: 0,
OriginalPlanId: 222,
},
}
expectedJSONAlt, _ := json.Marshal(expectedAlt)

// Query: 1, 0, Plan: 1, 0
// Query: 1, 0, Plan: 1, 0 (w/ QueryIdx 0)
expectedAlt.QueryPlanReferences = []*pganalyze_collector.QueryPlanReference{
&pganalyze_collector.QueryPlanReference{
QueryIdx: 1,
QueryIdx: 0,
OriginalPlanId: 222,
},
&pganalyze_collector.QueryPlanReference{
QueryIdx: 1,
QueryIdx: 0,
OriginalPlanId: 111,
},
}
Expand Down Expand Up @@ -208,7 +218,7 @@ func TestStatements(t *testing.T) {
}
expectedJSONAlt2, _ := json.Marshal(expectedAlt)

// Query: 0, 1, Plan: 1, 0
// Query: 0, 1, Plan: 1, 0 (w/ QueryIdx 1)
expectedAlt.QueryReferences = []*pganalyze_collector.QueryReference{
&pganalyze_collector.QueryReference{
DatabaseIdx: 0,
Expand Down Expand Up @@ -243,6 +253,16 @@ func TestStatements(t *testing.T) {
Calls: 13,
},
}
expectedAlt.QueryPlanReferences = []*pganalyze_collector.QueryPlanReference{
&pganalyze_collector.QueryPlanReference{
QueryIdx: 1,
OriginalPlanId: 222,
},
&pganalyze_collector.QueryPlanReference{
QueryIdx: 1,
OriginalPlanId: 111,
},
}
expectedJSONAlt3, _ := json.Marshal(expectedAlt)

if string(expectedJSON) != string(actualJSON) &&
Expand Down

0 comments on commit 61e0193

Please sign in to comment.