Skip to content

Commit

Permalink
update golden files for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Trey Ivy committed Sep 29, 2024
1 parent 46d547a commit bb0c614
Show file tree
Hide file tree
Showing 20 changed files with 11,966 additions and 14 deletions.
11 changes: 10 additions & 1 deletion internal/graphql/graphql_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,16 @@ func newMockServer(t *testing.T, entDataSource string) *mockServer {
}

require.FileExists(t, entDataSource)
entDataSource = "file:" + entDataSource + "?mode=ro&_fk=1"

var mode string
if *update {
mode = "?mode=rw&_fk=1"
} else {
mode = "?mode=ro&_fk=1"
}

entDataSource = "file:" + entDataSource + mode

client := enttest.Open(t, "sqlite3", entDataSource)

graphQLHandler := handler.NewDefaultServer(graphql.NewSchema(client))
Expand Down
Binary file modified internal/graphql/testdata/snapshot.db
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"endedAt": "2024-05-13T23:43:26.247Z",
"id": "QmF6ZWxJbnZvY2F0aW9uOjU=",
"invocationID": "571d0839-fd63-4442-bb4d-61f7bfa4ddae",
"metrics": null,
"problems": [
{
"__typename": "TestProblem",
Expand Down Expand Up @@ -72,7 +73,13 @@
},
"id": ""
},
"stepLabel": "nextjs_test"
"stepLabel": "nextjs_test",
"targets": [],
"testCollection": [],
"user": {
"Email": "",
"LDAP": ""
}
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"endedAt": "2024-05-13T23:43:26.247Z",
"id": "QmF6ZWxJbnZvY2F0aW9uOjU=",
"invocationID": "571d0839-fd63-4442-bb4d-61f7bfa4ddae",
"metrics": null,
"problems": [
{
"__typename": "TestProblem",
Expand Down Expand Up @@ -72,7 +73,13 @@
},
"id": ""
},
"stepLabel": "nextjs_test"
"stepLabel": "nextjs_test",
"targets": [],
"testCollection": [],
"user": {
"Email": "",
"LDAP": ""
}
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"endedAt": "2024-05-13T23:43:26.247Z",
"id": "QmF6ZWxJbnZvY2F0aW9uOjU=",
"invocationID": "571d0839-fd63-4442-bb4d-61f7bfa4ddae",
"metrics": null,
"problems": [
{
"__typename": "TestProblem",
Expand Down Expand Up @@ -61,6 +62,12 @@
},
"id": ""
},
"stepLabel": "nextjs_test"
"stepLabel": "nextjs_test",
"targets": [],
"testCollection": [],
"user": {
"Email": "",
"LDAP": ""
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"endedAt": "2024-05-03T00:29:47.784Z",
"id": "QmF6ZWxJbnZvY2F0aW9uOjM=",
"invocationID": "df7178e2-a815-4654-a409-d18e845d1e35",
"metrics": null,
"problems": [
{
"__typename": "ProgressProblem",
Expand Down Expand Up @@ -41,6 +42,12 @@
},
"id": ""
},
"stepLabel": ""
"stepLabel": "",
"targets": [],
"testCollection": [],
"user": {
"Email": "",
"LDAP": ""
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"endedAt": "2024-05-03T00:24:16.367Z",
"id": "QmF6ZWxJbnZvY2F0aW9uOjI=",
"invocationID": "08ae089d-4c85-405c-83fc-dbe9fc1dc942",
"metrics": null,
"problems": [
{
"__typename": "ActionProblem",
Expand Down Expand Up @@ -48,6 +49,12 @@
},
"id": ""
},
"stepLabel": ""
"stepLabel": "",
"targets": [],
"testCollection": [],
"user": {
"Email": "",
"LDAP": ""
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"endedAt": "2024-05-03T00:24:29.605Z",
"id": "QmF6ZWxJbnZvY2F0aW9uOjE=",
"invocationID": "fd03240f-697e-4b64-95bc-888e27445bf9",
"metrics": null,
"problems": [],
"relatedFiles": [
{
Expand All @@ -34,6 +35,12 @@
},
"id": ""
},
"stepLabel": ""
"stepLabel": "",
"targets": [],
"testCollection": [],
"user": {
"Email": "",
"LDAP": ""
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"endedAt": "2024-05-03T00:23:40.441Z",
"id": "QmF6ZWxJbnZvY2F0aW9uOjQ=",
"invocationID": "10a37e86-6e2b-4adb-83dd-c2906f42bdd6",
"metrics": null,
"problems": [],
"relatedFiles": [
{
Expand All @@ -34,6 +35,12 @@
},
"id": ""
},
"stepLabel": ""
"stepLabel": "",
"targets": [],
"testCollection": [],
"user": {
"Email": "",
"LDAP": ""
}
}
}
29 changes: 28 additions & 1 deletion pkg/summary/summarizer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,35 @@ func testDirectory(t *testing.T, baseDir string) error {
file := filepath.Join(baseDir, name)
gotSummary, err := summary.Summarize(ctx, file)

//the timestamps and duration related fields can and will differ between runs, so we need to zero these out
for label, target := range gotSummary.Targets {
target.DurationInMs = 0
target.Configuration.StartTimeInMs = 0
target.Completion.EndTimeInMs = 0
gotSummary.Targets[label] = target
}

for label, test := range gotSummary.Tests {
test.DurationMs = 0
test.TestSummary.FirstStartTime = 0
test.TestSummary.LastStopTime = 0
for i := range test.TestResults {
test.TestResults[i].TestAttemptDuration = 0
test.TestResults[i].ExecutionInfo.TimingBreakdown.Time = "0"
for z := range test.TestResults[i].ExecutionInfo.TimingBreakdown.Child {
test.TestResults[i].ExecutionInfo.TimingBreakdown.Child[z].Time = "0"
}
}
gotSummary.Tests[label] = test
}

require.NoError(t, err)
testkit.CheckAgainstGoldenFile(t, map[string]interface{}{"summary": gotSummary}, snapshotPath, name, update, nil)

//i don't know that this actually has any effect, but setting it just in case
opts := testkit.CompareOptions{
DateTimeAgnostic: true,
}
testkit.CheckAgainstGoldenFile(t, map[string]interface{}{"summary": gotSummary}, snapshotPath, name, update, &opts)
})
}

Expand Down
Loading

0 comments on commit bb0c614

Please sign in to comment.