Skip to content

Commit

Permalink
test(unit): add coverage of printing in limited height
Browse files Browse the repository at this point in the history
Signed-off-by: Billy Zha <[email protected]>
  • Loading branch information
qweeah committed Jul 19, 2024
1 parent 3aeba86 commit ce2146e
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions cmd/oras/internal/display/status/progress/manager_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
Copyright The ORAS Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package progress

import (
"fmt"
"testing"

"oras.land/oras/cmd/oras/internal/display/status/console"
"oras.land/oras/cmd/oras/internal/display/status/console/testutils"
)

func Test_manager_render(t *testing.T) {
pty, device, err := testutils.NewPty()
if err != nil {
t.Fatal(err)
}
defer device.Close()
m := &manager{
console: &console.Console{Console: pty},
}
_, height := m.console.Size()
for i := 0; i < height; i++ {
m.Add()

Check failure on line 37 in cmd/oras/internal/display/status/progress/manager_test.go

View workflow job for this annotation

GitHub Actions / lint (1.22)

Error return value of `m.Add` is not checked (errcheck)
}
m.render()
// validate
var want []string
for i := height; i > 0; i -= 2 {
want = append(want, fmt.Sprintf("%dF%s", i, zeroStatus))
}
if err = testutils.MatchPty(pty, device, want...); err != nil {
t.Fatal(err)
}
}

0 comments on commit ce2146e

Please sign in to comment.