-
Notifications
You must be signed in to change notification settings - Fork 55
test: improve render coverage from 78.5% to 86.9% #67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -81,3 +81,18 @@ func TestCloneAnimationBuildFrame(t *testing.T) { | |||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| func TestCloneAnimationDemo(t *testing.T) { | ||||||||||||||||||||||||||||
| var buf bytes.Buffer | ||||||||||||||||||||||||||||
| a := NewCloneAnimation(&buf, "repo") | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| a.Demo() | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| out := buf.String() | ||||||||||||||||||||||||||||
| if !strings.Contains(out, "100%") { | ||||||||||||||||||||||||||||
| t.Fatalf("expected demo output to reach 100%%, got %q", out) | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| if !strings.HasSuffix(out, "\n") { | ||||||||||||||||||||||||||||
| t.Fatalf("expected demo output to end with newline, got %q", out) | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
Comment on lines
+86
to
+97
|
||||||||||||||||||||||||||||
| var buf bytes.Buffer | |
| a := NewCloneAnimation(&buf, "repo") | |
| a.Demo() | |
| out := buf.String() | |
| if !strings.Contains(out, "100%") { | |
| t.Fatalf("expected demo output to reach 100%%, got %q", out) | |
| } | |
| if !strings.HasSuffix(out, "\n") { | |
| t.Fatalf("expected demo output to end with newline, got %q", out) | |
| } | |
| t.Skip("Demo() performs real time.Sleep calls; skipping in unit tests to keep the suite fast") |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,9 @@ package render | |
|
|
||
| import ( | ||
| "bytes" | ||
| "io" | ||
| "math/rand/v2" | ||
| "os" | ||
| "path/filepath" | ||
| "regexp" | ||
| "strings" | ||
|
|
@@ -418,3 +420,39 @@ func TestSkylineMinMax(t *testing.T) { | |
| }) | ||
| } | ||
| } | ||
|
|
||
| func TestSkylineAnimatePathCallsRenderAnimatedForStdout(t *testing.T) { | ||
| project := scanner.Project{ | ||
| Root: t.TempDir(), | ||
| Name: "Demo", | ||
| Files: []scanner.FileInfo{ | ||
| {Path: "main.go", Ext: ".go", Size: 100}, | ||
| }, | ||
| } | ||
|
|
||
| origStdout := os.Stdout | ||
| r, w, err := os.Pipe() | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| os.Stdout = w | ||
| t.Cleanup(func() { | ||
| os.Stdout = origStdout | ||
| }) | ||
|
|
||
| done := make(chan string, 1) | ||
| go func() { | ||
| data, _ := io.ReadAll(r) | ||
| done <- string(data) | ||
| }() | ||
|
|
||
| Skyline(w, project, true) | ||
|
|
||
| if err := w.Close(); err != nil { | ||
| t.Fatal(err) | ||
| } | ||
|
Comment on lines
+433
to
+453
|
||
| out := <-done | ||
| if !strings.Contains(out, "Demo") { | ||
| t.Fatalf("expected skyline output to include project name, got:\n%s", out) | ||
| } | ||
| } | ||
|
Comment on lines
+424
to
+458
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TestCloneAnimationDemoinvokesDemo(), which sleeps80msfor each of 51 frames plus a final500mspause, adding about 4.6 seconds to every run of this package even though the assertion only checks final output content. This materially slows local/CI feedback loops and is avoidable by testingRender/buildFramedirectly or injecting a mock sleeper/clock.Useful? React with 👍 / 👎.