From b81580081b8318170eaa581fda8d082314b58a2a Mon Sep 17 00:00:00 2001 From: Alexander Todorov Date: Fri, 13 Mar 2020 11:35:50 +0100 Subject: [PATCH] Use asserts in tests. Refs #309 --- cmd/osbuild-dnf-json-tests/main_test.go | 17 +++++------------ go.mod | 2 +- vendor/modules.txt | 8 ++++++++ 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/cmd/osbuild-dnf-json-tests/main_test.go b/cmd/osbuild-dnf-json-tests/main_test.go index 968963cfb..aa088187a 100644 --- a/cmd/osbuild-dnf-json-tests/main_test.go +++ b/cmd/osbuild-dnf-json-tests/main_test.go @@ -11,6 +11,7 @@ import ( "os" "os/exec" "testing" + "github.com/stretchr/testify/assert" "path" ) @@ -39,13 +40,9 @@ func TestFetchChecksum(t *testing.T) { dir, err := setUpTemporaryRepository() defer func(dir string) { err := tearDownTemporaryRepository(dir) - if err != nil { - t.Errorf("Warning: failed to clean up temporary repository.") - } + assert.Nil(t, err, "Failed to clean up temporary repository.") }(dir) - if err != nil { - t.Fatalf("Failed to set up temporary repository: %v", err) - } + assert.Nilf(t, err, "Failed to set up temporary repository: %v", err) repoCfg := rpmmd.RepoConfig{ Id: "repo", @@ -55,10 +52,6 @@ func TestFetchChecksum(t *testing.T) { } rpmMetadata := rpmmd.NewRPMMD(path.Join(dir, "rpmmd")) _, c, err := rpmMetadata.FetchMetadata([]rpmmd.RepoConfig{repoCfg}, "platform:f31") - if err != nil { - t.Fatalf("Failed to fetch checksum: %v", err) - } - if c["repo"] == "" { - t.Errorf("The checksum is empty") - } + assert.Nilf(t, err, "Failed to fetch checksum: %v", err) + assert.NotEqual(t, "", c["repo"], "The checksum is empty") } diff --git a/go.mod b/go.mod index 5dcdb516e..a00a8ba58 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/google/uuid v1.1.1 github.com/julienschmidt/httprouter v1.2.0 github.com/pkg/errors v0.9.1 // indirect - github.com/stretchr/testify v1.4.0 // indirect + github.com/stretchr/testify v1.4.0 golang.org/x/net v0.0.0-20200202094626-16171245cfb2 // indirect golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4 // indirect ) diff --git a/vendor/modules.txt b/vendor/modules.txt index 78a9f180c..7fc5b0635 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -50,6 +50,8 @@ github.com/aws/aws-sdk-go/service/sts/stsiface github.com/coreos/go-semver/semver # github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f github.com/coreos/go-systemd/activation +# github.com/davecgh/go-spew v1.1.0 +github.com/davecgh/go-spew/spew # github.com/gobwas/glob v0.2.3 github.com/gobwas/glob github.com/gobwas/glob/compiler @@ -74,6 +76,10 @@ github.com/jmespath/go-jmespath github.com/julienschmidt/httprouter # github.com/mattn/go-ieproxy v0.0.0-20190610004146-91bb50d98149 github.com/mattn/go-ieproxy +# github.com/pmezard/go-difflib v1.0.0 +github.com/pmezard/go-difflib/difflib +# github.com/stretchr/testify v1.4.0 +github.com/stretchr/testify/assert # golang.org/x/net v0.0.0-20200202094626-16171245cfb2 golang.org/x/net/http/httpproxy golang.org/x/net/idna @@ -85,3 +91,5 @@ golang.org/x/text/secure/bidirule golang.org/x/text/transform golang.org/x/text/unicode/bidi golang.org/x/text/unicode/norm +# gopkg.in/yaml.v2 v2.2.2 +gopkg.in/yaml.v2