Skip to content

Commit 59b7ec4

Browse files
committed
Reduce dependencies
1 parent ea75176 commit 59b7ec4

3 files changed

Lines changed: 27 additions & 28 deletions

File tree

go.mod

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
11
module github.com/bool64/dev
22

33
go 1.17
4-
5-
require github.com/stretchr/testify v1.4.0
6-
7-
require (
8-
github.com/davecgh/go-spew v1.1.0 // indirect
9-
github.com/pmezard/go-difflib v1.0.0 // indirect
10-
gopkg.in/yaml.v2 v2.2.2 // indirect
11-
)

go.sum

Lines changed: 0 additions & 11 deletions
This file was deleted.

version/info_test.go

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import (
44
"fmt"
55
"runtime"
66
"testing"
7-
8-
"github.com/stretchr/testify/assert"
97
)
108

119
func TestInformation_String(t *testing.T) {
@@ -15,16 +13,19 @@ func TestInformation_String(t *testing.T) {
1513
buildDate = ""
1614
buildUser = ""
1715

18-
assert.Equal(t, "Version: v3.2.1, GoVersion: "+runtime.Version(), Info().String())
16+
equal(t, "Version: v3.2.1, GoVersion: "+runtime.Version(), Info().String())
1917

2018
version = "v1.2.3"
2119
branch = "refs/heads/master"
2220
revision = "111765232072440cc598b189e284c9a4450a6018"
2321
buildUser = "user"
2422
buildDate = "2021-01-13 22:13:41"
2523

26-
assert.Equal(t, fmt.Sprintf("Version: %s, Revision: %s, Branch: %s, BuildUser: %s, BuildDate: %s, GoVersion: %s",
27-
version, revision, branch, buildUser, buildDate, runtime.Version()), Info().String())
24+
expected := fmt.Sprintf("Version: %s, Revision: %s, Branch: %s, BuildUser: %s, BuildDate: %s, GoVersion: %s",
25+
version, revision, branch, buildUser, buildDate, runtime.Version())
26+
received := Info().String()
27+
28+
equal(t, expected, received)
2829
}
2930

3031
func TestInformation_Values(t *testing.T) {
@@ -34,19 +35,36 @@ func TestInformation_Values(t *testing.T) {
3435
buildDate = ""
3536
buildUser = ""
3637

37-
assert.Equal(t, map[string]string{
38+
equal(t, fmt.Sprintf("%v", map[string]string{
3839
"branch": "", "build_date": "", "build_user": "", "go_version": runtime.Version(),
3940
"revision": "", "version": "v3.2.1",
40-
}, Info().Values())
41+
}), fmt.Sprintf("%v", Info().Values()))
4142

4243
version = "v1.2.3"
4344
branch = "refs/heads/master"
4445
revision = "111765232072440cc598b189e284c9a4450a6018"
4546
buildDate = "2021-01-13 22:13:41"
4647
buildUser = "user"
4748

48-
assert.Equal(t, map[string]string{
49+
equal(t, fmt.Sprintf("%v", map[string]string{
50+
"branch": branch, "build_date": buildDate, "build_user": buildUser,
51+
"go_version": runtime.Version(), "revision": revision, "version": version,
52+
}), fmt.Sprintf("%v", Info().Values()))
53+
54+
expected := fmt.Sprintf("%v", map[string]string{
4955
"branch": branch, "build_date": buildDate, "build_user": buildUser,
5056
"go_version": runtime.Version(), "revision": revision, "version": version,
51-
}, Info().Values())
57+
})
58+
59+
received := fmt.Sprintf("%v", Info().Values())
60+
61+
equal(t, expected, received)
62+
}
63+
64+
func equal(t *testing.T, expected, received string) {
65+
t.Helper()
66+
67+
if expected != received {
68+
t.Fatalf("%q is expected, %s received", expected, received)
69+
}
5270
}

0 commit comments

Comments
 (0)