Skip to content

Commit

Permalink
Update tests for package elapsed time change.
Browse files Browse the repository at this point in the history
  • Loading branch information
dnephin committed Aug 28, 2021
1 parent ed34d9a commit 95d34ff
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 136 deletions.
4 changes: 2 additions & 2 deletions testjson/dotformat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ func TestFmtDotElapsed(t *testing.T) {
for _, tc := range testcases {
t.Run(tc.expected, func(t *testing.T) {
pkg := &Package{
cached: tc.cached,
Passed: []TestCase{{Elapsed: tc.elapsed}},
cached: tc.cached,
elapsed: tc.elapsed,
}
actual := fmtDotElapsed(pkg)
assert.Check(t, cmp.Equal(utf8.RuneCountInString(actual), 7))
Expand Down
20 changes: 2 additions & 18 deletions testjson/execution_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,6 @@ import (
"gotest.tools/v3/golden"
)

func TestPackage_Elapsed(t *testing.T) {
pkg := &Package{
Failed: []TestCase{
{Elapsed: 300 * time.Millisecond},
},
Passed: []TestCase{
{Elapsed: 200 * time.Millisecond},
{Elapsed: 2500 * time.Millisecond},
},
Skipped: []TestCase{
{Elapsed: 100 * time.Millisecond},
},
}
assert.Equal(t, pkg.Elapsed(), 3100*time.Millisecond)
}

func TestExecution_Add_PackageCoverage(t *testing.T) {
exec := newExecution()
exec.add(TestEvent{
Expand Down Expand Up @@ -144,7 +128,7 @@ func TestPackage_AddEvent(t *testing.T) {
{
name: "package failed",
event: `{"Action":"fail","Package":"gotest.tools/testing","Elapsed":0.012}`,
expected: Package{action: ActionFail},
expected: Package{action: ActionFail, elapsed: 12 * time.Millisecond},
},
{
name: "package is cached",
Expand All @@ -157,7 +141,7 @@ func TestPackage_AddEvent(t *testing.T) {
{
name: "package pass",
event: `{"Action":"pass","Package":"gotest.tools/testing","Elapsed":0.012}`,
expected: Package{action: ActionPass},
expected: Package{action: ActionPass, elapsed: 12 * time.Millisecond},
},
}

Expand Down
8 changes: 7 additions & 1 deletion testjson/format_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,18 @@ var expectedExecution = &Execution{
{Test: "TestSkipped"},
{Test: "TestSkippedWitLog"},
},
elapsed: 11 * time.Millisecond,
action: ActionFail,
running: map[string]TestCase{},
},
"github.com/gotestyourself/gotestyourself/testjson/internal/badmain": {
action: ActionFail,
running: map[string]TestCase{},
elapsed: 10 * time.Millisecond,
},
"gotest.tools/gotestsum/internal/empty": {
action: ActionPass,
action: ActionPass,
elapsed: 4 * time.Millisecond,
},
},
}
Expand Down Expand Up @@ -224,6 +227,7 @@ var expectedCoverageExecution = &Execution{
{Test: "TestSkipped"},
{Test: "TestSkippedWitLog"},
},
elapsed: 12 * time.Millisecond,
action: ActionPass,
coverage: "coverage: 0.0% of statements",
running: map[string]TestCase{},
Expand All @@ -240,13 +244,15 @@ var expectedCoverageExecution = &Execution{
{Test: "TestSkipped"},
{Test: "TestSkippedWitLog"},
},
elapsed: 11 * time.Millisecond,
action: ActionFail,
coverage: "coverage: 0.0% of statements",
running: map[string]TestCase{},
},
"gotest.tools/gotestsum/testjson/internal/badmain": {
action: ActionFail,
running: map[string]TestCase{},
elapsed: time.Millisecond,
},
},
}
Loading

0 comments on commit 95d34ff

Please sign in to comment.