remove testing dependencies

This commit is contained in:
2021-05-24 00:11:58 +03:00
parent 0823f3e5bd
commit c042482a2f
5 changed files with 67 additions and 33 deletions

View File

@@ -4,11 +4,10 @@ import (
"archive/tar"
"bytes"
"encoding/json"
"reflect"
"testing"
"git.sr.ht/~motiejus/code/undocker/internal/tartest"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
type (
@@ -193,13 +192,22 @@ func TestRootFS(t *testing.T) {
err := Flatten(in, &out)
if tt.wantErr != "" {
assert.EqualError(t, err, tt.wantErr)
if err == nil {
t.Fatal("expected error, got nil")
}
if tt.wantErr != err.Error() {
t.Errorf("want != got: %s != %s", tt.wantErr, err.Error())
}
return
}
outb := out.Bytes()
require.NoError(t, err)
if err != nil {
t.Fatal("expected error, got nil")
}
got := tartest.Extract(t, bytes.NewReader(outb))
assert.Equal(t, tt.want, got)
if !reflect.DeepEqual(tt.want, got) {
t.Errorf("want != got: %v != %v", tt.want, got)
}
})
}
}

View File

@@ -37,15 +37,17 @@ func TestTree(t *testing.T) {
for _, path := range tt.matchTrue {
t.Run(path, func(t *testing.T) {
assert.True(t, tree.HasPrefix(path),
"expected %s to be a prefix of %s", path, tree)
if !tree.HasPrefix(path) {
t.Errorf("expected %s to be a prefix of %s", path, tree)
}
})
}
for _, path := range tt.matchFalse {
t.Run(path, func(t *testing.T) {
assert.False(t, tree.HasPrefix(path),
"expected %s to not be a prefix of %s", path, tree)
if tree.HasPrefix(path) {
t.Errorf("expected %s to not be a prefix of %s", path, tree)
}
})
}
})
@@ -56,8 +58,14 @@ func TestTreeMerge(t *testing.T) {
tree1 := newTree("bin/ar", "var/cache/apt")
tree2 := newTree("bin/ar", "bin/busybox", "usr/share/doc")
tree1.Merge(tree2)
assert.Equal(t, "./bin/ar:./bin/busybox:./usr/share/doc:./var/cache/apt", tree1.String())
assert.Equal(t, "./bin/ar:./bin/busybox:./usr/share/doc", tree2.String())
want1 := "./bin/ar:./bin/busybox:./usr/share/doc:./var/cache/apt"
if got := tree1.String(); want1 != got {
t.Errorf("want != got: %q != %q", want1, got)
}
want2 := "./bin/ar:./bin/busybox:./usr/share/doc"
if got := tree2.String(); want2 != got {
t.Errorf("want != got: %q != %q", want2, got)
}
}
func TestString(t *testing.T) {