Skip to content

Commit 687262b

Browse files
author
David Cavazos
committed
use manual test checks
1 parent cc7fd6b commit 687262b

File tree

2 files changed

+38
-58
lines changed

2 files changed

+38
-58
lines changed

.github/cloud-samples-tools/test/config_test.go

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
c "cloud-samples-tools/pkg/config"
55
"os"
66
"path/filepath"
7+
"reflect"
78
"testing"
89
)
910

@@ -36,18 +37,23 @@ func TestLoadConfig(t *testing.T) {
3637
for _, test := range tests {
3738
path := filepath.Join("testdata", "config", test.filename)
3839
got, err := c.LoadConfig(path)
39-
if test.fails {
40-
expectError(t, err)
41-
continue
40+
if test.fails && err == nil {
41+
t.Fatal("expected failure\n", got)
42+
}
43+
if !test.fails && err != nil {
44+
t.Fatal("error loading config\n", err)
45+
}
46+
if !reflect.DeepEqual(test.config, got) {
47+
t.Fatal("expected equal\n", test.config, got)
4248
}
43-
ok(t, err)
44-
equals(t, test.config, got)
4549
}
4650
}
4751

4852
func TestSaveLoadConfig(t *testing.T) {
4953
file, err := os.CreateTemp("", "config-*.json")
50-
ok(t, err)
54+
if err != nil {
55+
t.Fatal("error creating temp file\n", err)
56+
}
5157
defer os.Remove(file.Name())
5258

5359
config := c.Config{
@@ -57,12 +63,23 @@ func TestSaveLoadConfig(t *testing.T) {
5763
ExcludePackages: []string{"excluded"},
5864
}
5965
err = config.Save(file)
60-
ok(t, err)
66+
if err != nil {
67+
t.Fatal("error saving config\n", err)
68+
}
69+
70+
err = file.Close()
71+
if err != nil {
72+
t.Fatal("error closing file\n", err)
73+
}
6174

6275
loadedConfig, err := c.LoadConfig(file.Name())
63-
ok(t, err)
76+
if err != nil {
77+
t.Fatal("error loading config\n", err)
78+
}
6479

65-
equals(t, &config, loadedConfig)
80+
if !reflect.DeepEqual(&config, loadedConfig) {
81+
t.Fatal("expected equal\n", &config, loadedConfig)
82+
}
6683
}
6784

6885
func TestMatch(t *testing.T) {
@@ -90,7 +107,9 @@ func TestMatch(t *testing.T) {
90107

91108
for _, test := range tests {
92109
got := c.Match(test.patterns, test.path)
93-
equals(t, test.expected, got)
110+
if got != test.expected {
111+
t.Fatal("expected equal\n", test.expected, got)
112+
}
94113
}
95114
}
96115

@@ -112,7 +131,9 @@ func TestIsPackage(t *testing.T) {
112131

113132
for _, test := range tests {
114133
got := config.IsPackageDir(test.path)
115-
equals(t, test.expected, got)
134+
if test.expected != got {
135+
t.Fatal("expected equal\n", test.expected, got)
136+
}
116137
}
117138
}
118139

@@ -138,7 +159,9 @@ func TestFindPackage(t *testing.T) {
138159

139160
for _, test := range tests {
140161
got := config.FindPackage(test.path)
141-
equals(t, test.expected, got)
162+
if test.expected != got {
163+
t.Fatal("expected equal\n", test.expected, got)
164+
}
142165
}
143166
}
144167

@@ -168,6 +191,8 @@ func TestChanged(t *testing.T) {
168191

169192
for _, test := range tests {
170193
got := config.Changed(test.diffs)
171-
equals(t, test.expected, got)
194+
if !reflect.DeepEqual(test.expected, got) {
195+
t.Fatal("expected equal\n", test.expected, got)
196+
}
172197
}
173198
}

.github/cloud-samples-tools/test/utils.go

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

0 commit comments

Comments
 (0)