Skip to content

Commit 5ef096d

Browse files
Lint test files (#20)
1 parent ae03f76 commit 5ef096d

4 files changed

Lines changed: 14 additions & 9 deletions

File tree

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,5 @@ lint:
2929
@EXPECTED=$$(awk '/^golangci-lint/ {print $$2}' .tool-versions); \
3030
INSTALLED=$$(golangci-lint version --short 2>/dev/null | sed 's/^v//'); \
3131
[ "$$INSTALLED" = "$$EXPECTED" ] || { echo "golangci-lint $$EXPECTED required (found: $$INSTALLED)"; exit 1; }
32-
golangci-lint run
32+
golangci-lint run --tests ./...
33+
(cd test/integration && golangci-lint run --tests ./...)

test/integration/config_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func TestConfigFileCreatedOnStartup(t *testing.T) {
3838
cmd.Env = env
3939
err := cmd.Start()
4040
require.NoError(t, err, "failed to start lstk")
41-
defer cmd.Process.Kill()
41+
defer func() { _ = cmd.Process.Kill() }()
4242

4343
// Poll for config file creation - check every 50ms, timeout after 2s
4444
require.Eventually(t, func() bool {

test/integration/login_browser_flow_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func TestBrowserFlowStoresToken(t *testing.T) {
2525
// Keep stdin open so ENTER listener doesn't trigger immediately
2626
stdinPipe, err := cmd.StdinPipe()
2727
require.NoError(t, err)
28-
defer stdinPipe.Close()
28+
defer func() { _ = stdinPipe.Close() }()
2929

3030
// Capture output asynchronously
3131
output := make(chan []byte)

test/integration/login_device_flow_test.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,30 +25,34 @@ func createMockAPIServer(t *testing.T, licenseToken string) *httptest.Server {
2525
switch {
2626
case r.Method == "POST" && r.URL.Path == "/v1/auth/request":
2727
w.WriteHeader(http.StatusCreated)
28-
json.NewEncoder(w).Encode(map[string]string{
28+
err := json.NewEncoder(w).Encode(map[string]string{
2929
"id": authReqID,
3030
"code": "TEST123",
3131
"exchange_token": exchangeToken,
3232
})
33+
require.NoError(t, err)
3334

3435
case r.Method == "GET" && r.URL.Path == fmt.Sprintf("/v1/auth/request/%s", authReqID):
3536
w.WriteHeader(http.StatusOK)
36-
json.NewEncoder(w).Encode(map[string]bool{
37+
err := json.NewEncoder(w).Encode(map[string]bool{
3738
"confirmed": true,
3839
})
40+
require.NoError(t, err)
3941

4042
case r.Method == "POST" && r.URL.Path == fmt.Sprintf("/v1/auth/request/%s/exchange", authReqID):
4143
w.WriteHeader(http.StatusOK)
42-
json.NewEncoder(w).Encode(map[string]string{
44+
err := json.NewEncoder(w).Encode(map[string]string{
4345
"id": authReqID,
4446
"auth_token": bearerToken,
4547
})
48+
require.NoError(t, err)
4649

4750
case r.Method == "GET" && r.URL.Path == "/v1/license/credentials":
4851
w.WriteHeader(http.StatusOK)
49-
json.NewEncoder(w).Encode(map[string]string{
52+
err := json.NewEncoder(w).Encode(map[string]string{
5053
"token": licenseToken,
5154
})
55+
require.NoError(t, err)
5256

5357
default:
5458
t.Logf("Unhandled request: %s %s", r.Method, r.URL.Path)
@@ -81,7 +85,7 @@ func TestDeviceFlowSuccess(t *testing.T) {
8185
// Keep stdin open and get the pipe to simulate ENTER
8286
stdinPipe, err := cmd.StdinPipe()
8387
require.NoError(t, err)
84-
defer stdinPipe.Close()
88+
defer func() { _ = stdinPipe.Close() }()
8589

8690
outputCh := make(chan []byte, 1)
8791
go func() {
@@ -140,7 +144,7 @@ func TestDeviceFlowFailure_RequestNotConfirmed(t *testing.T) {
140144
// Keep stdin open and get the pipe to simulate ENTER
141145
stdinPipe, err := cmd.StdinPipe()
142146
require.NoError(t, err)
143-
defer stdinPipe.Close()
147+
defer func() { _ = stdinPipe.Close() }()
144148

145149
outputCh := make(chan []byte, 1)
146150
go func() {

0 commit comments

Comments
 (0)