Skip to content

Commit 597acd3

Browse files
remove weak tests
1 parent dfe1d2a commit 597acd3

7 files changed

Lines changed: 0 additions & 202 deletions

File tree

checks/cli.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,6 @@ func (b *boundedBuffer) String() string {
5858
return b.buffer.String()
5959
}
6060

61-
func (b *boundedBuffer) Truncated() bool {
62-
return b.truncated
63-
}
64-
6561
func runCLICommand(command api.CLIStepCLICommand, variables map[string]string) (result api.CLICommandResult) {
6662
return runCLICommandWithLimits(command, variables, cliCommandTimeout, maxCLIOutputBytesPerStream)
6763
}

checks/cli_test.go

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -74,30 +74,6 @@ func TestRunCLICommandCapsOutput(t *testing.T) {
7474
}
7575
}
7676

77-
func TestBoundedBufferDiscardsExcessBytes(t *testing.T) {
78-
truncations := 0
79-
buffer := newBoundedBuffer(5, func() {
80-
truncations++
81-
})
82-
written, err := buffer.Write([]byte("abcdefgh"))
83-
if err != nil {
84-
t.Fatalf("Write() error = %v", err)
85-
}
86-
if written != 8 {
87-
t.Fatalf("Write() = %d, want 8", written)
88-
}
89-
if got := buffer.String(); got != "abcde" {
90-
t.Fatalf("buffer = %q, want abcde", got)
91-
}
92-
if !buffer.Truncated() {
93-
t.Fatal("buffer did not record truncation")
94-
}
95-
_, _ = buffer.Write([]byte("more"))
96-
if truncations != 1 {
97-
t.Fatalf("truncation callback invoked %d times, want once", truncations)
98-
}
99-
}
100-
10177
func TestRunCLICommandCapturesStdoutVariables(t *testing.T) {
10278
variables := map[string]string{}
10379
result := runCLICommand(api.CLIStepCLICommand{
@@ -178,21 +154,6 @@ func TestRunCLICommandInterpolatesCapturedStdoutVariables(t *testing.T) {
178154
}
179155
}
180156

181-
func TestParseStdoutVariablesRequiresOneCaptureGroup(t *testing.T) {
182-
variables := map[string]string{}
183-
err := parseStdoutVariables("token=abc123", []api.CLICommandStdoutVariable{{
184-
Name: "token",
185-
Regex: `token=([a-z]+)([0-9]+)`,
186-
}}, variables)
187-
188-
if err == nil {
189-
t.Fatal("expected parse error")
190-
}
191-
if err.Error() != "invalid stdout variable configuration" {
192-
t.Fatalf("error = %q, want invalid stdout variable configuration", err.Error())
193-
}
194-
}
195-
196157
func TestParseStdoutVariablesUsesGenericConfigurationError(t *testing.T) {
197158
tests := []struct {
198159
name string

checks/http_test.go

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"net/http/httptest"
88
"strings"
99
"testing"
10-
"time"
1110

1211
api "github.com/bootdotdev/bootdev/client"
1312
)
@@ -240,39 +239,6 @@ func TestRunHTTPRequestCapsResponseBodyRead(t *testing.T) {
240239
}
241240
}
242241

243-
func TestRunHTTPRequestHonorsClientTimeout(t *testing.T) {
244-
const timeout = 20 * time.Millisecond
245-
client := &http.Client{
246-
Timeout: timeout,
247-
Transport: httpRoundTripFunc(func(r *http.Request) (*http.Response, error) {
248-
<-r.Context().Done()
249-
return nil, r.Context().Err()
250-
}),
251-
}
252-
requestStep := api.CLIStepHTTPRequest{
253-
Request: api.HTTPRequest{
254-
Method: http.MethodGet,
255-
FullURL: "http://example.test",
256-
},
257-
}
258-
259-
start := time.Now()
260-
result := runHTTPRequest(client, "", map[string]string{}, requestStep)
261-
elapsed := time.Since(start)
262-
if result.Err == "" {
263-
t.Fatal("runHTTPRequest() unexpectedly succeeded")
264-
}
265-
if elapsed > time.Second {
266-
t.Fatalf("runHTTPRequest() took %v, want a prompt timeout", elapsed)
267-
}
268-
}
269-
270-
func TestLessonHTTPClientUsesConfiguredTimeout(t *testing.T) {
271-
if got := newLessonHTTPClient().Timeout; got != lessonHTTPRequestTimeout {
272-
t.Fatalf("lesson HTTP client timeout = %v, want %v", got, lessonHTTPRequestTimeout)
273-
}
274-
}
275-
276242
func TestRunHTTPRequestCapturesResponseHeaderVariableAndDoesNotFollowRedirect(t *testing.T) {
277243
followRedirects := false
278244

checks/jq_test.go

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -97,34 +97,6 @@ func TestParseJqInputRejectsMultipleJSONValuesInJSONMode(t *testing.T) {
9797
}
9898
}
9999

100-
func TestFormatJqResults(t *testing.T) {
101-
got := formatJqResults([]any{"hello", float64(42), true, nil, map[string]any{"id": float64(1)}})
102-
want := []string{`"hello"`, `42`, `true`, `null`, `{"id":1}`}
103-
if !reflect.DeepEqual(got, want) {
104-
t.Fatalf("formatJqResults() = %#v, want %#v", got, want)
105-
}
106-
}
107-
108-
func TestFormatJqExpectedValueInterpolatesOnlyStrings(t *testing.T) {
109-
variables := map[string]string{"name": "Allan"}
110-
111-
gotString := formatJqExpectedValue(api.JqExpectedResult{
112-
Type: api.JqTypeString,
113-
Value: "hello ${name}",
114-
}, variables)
115-
if gotString != `"hello Allan"` {
116-
t.Fatalf("expected interpolated string value, got %q", gotString)
117-
}
118-
119-
gotInt := formatJqExpectedValue(api.JqExpectedResult{
120-
Type: api.JqTypeInt,
121-
Value: "${name}",
122-
}, variables)
123-
if gotInt != `"${name}"` {
124-
t.Fatalf("expected non-string jq type to avoid interpolation, got %q", gotInt)
125-
}
126-
}
127-
128100
func TestValFromJqPath(t *testing.T) {
129101
tests := []struct {
130102
name string

client/auth_test.go

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

cmd/logout_test.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,3 @@ func TestLogoutReturnsConfigWriteError(t *testing.T) {
7979
t.Fatalf("logout() error = %q, want config write error", err)
8080
}
8181
}
82-
83-
func TestLogoutCommandDoesNotRequireAuthentication(t *testing.T) {
84-
if logoutCmd.PreRun != nil {
85-
t.Fatal("logout command unexpectedly requires authentication")
86-
}
87-
}

version/version_test.go

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -10,37 +10,6 @@ import (
1010
"time"
1111
)
1212

13-
func TestGetLatestVersionRespectsGoProxyOff(t *testing.T) {
14-
if runtime.GOOS == "windows" {
15-
t.Skip("test uses a POSIX executable script")
16-
}
17-
18-
dir := t.TempDir()
19-
fakeGo := filepath.Join(dir, "go")
20-
script := `#!/bin/sh
21-
if [ "$GOPROXY" != "off" ]; then
22-
echo "unexpected GOPROXY: $GOPROXY" >&2
23-
exit 1
24-
fi
25-
printf '{"Version":"v1.2.3"}'
26-
`
27-
if err := os.WriteFile(fakeGo, []byte(script), 0o755); err != nil {
28-
t.Fatalf("create fake go command: %v", err)
29-
}
30-
t.Setenv("PATH", dir)
31-
t.Setenv("GOPROXY", "off")
32-
t.Setenv("GOPRIVATE", "")
33-
t.Setenv("GONOPROXY", "none")
34-
35-
latest, err := getLatestVersionWithTimeout(time.Second)
36-
if err != nil {
37-
t.Fatalf("get latest version: %v", err)
38-
}
39-
if latest != "v1.2.3" {
40-
t.Fatalf("latest version = %q, want v1.2.3", latest)
41-
}
42-
}
43-
4413
func TestGetLatestVersionHasOverallTimeout(t *testing.T) {
4514
if runtime.GOOS == "windows" {
4615
t.Skip("test uses a POSIX executable script")

0 commit comments

Comments
 (0)