Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
BINARY_NAME=lstk
ifeq ($(OS),Windows_NT)
BINARY_NAME=lstk.exe
endif
BUILD_DIR=bin

.PHONY: build clean test test-integration lint mock-generate

build:
$(BUILD_DIR)/$(BINARY_NAME):
go build -o $(BUILD_DIR)/$(BINARY_NAME) .

build: clean $(BUILD_DIR)/$(BINARY_NAME)

clean:
rm -rf $(BUILD_DIR)

test:
@JUNIT=""; [ -n "$$CREATE_JUNIT_REPORT" ] && JUNIT="--junitfile test-results.xml"; \
go run gotest.tools/gotestsum@latest --format testdox $$JUNIT -- ./cmd/... ./internal/...

test-integration: build
test-integration: $(BUILD_DIR)/$(BINARY_NAME)
@JUNIT=""; [ -n "$$CREATE_JUNIT_REPORT" ] && JUNIT="--junitfile ../../test-integration-results.xml"; \
cd test/integration && go run gotest.tools/gotestsum@latest --format testdox $$JUNIT -- -count=1 ./...

Expand Down
5 changes: 3 additions & 2 deletions test/integration/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ func TestConfigFileCreatedOnStartup(t *testing.T) {

configFile := filepath.Join(configDir, "config.toml")

cmd := exec.Command("../../bin/lstk", "start")
cmd := exec.Command(binaryPath(), "start")
cmd.Env = env
cmd.Start()
err := cmd.Start()
require.NoError(t, err, "failed to start lstk")
defer cmd.Process.Kill()

// Poll for config file creation - check every 50ms, timeout after 2s
Expand Down
4 changes: 2 additions & 2 deletions test/integration/logout_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func TestLogoutCommandRemovesToken(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()

cmd := exec.CommandContext(ctx, "../../bin/lstk", "logout")
cmd := exec.CommandContext(ctx, binaryPath(), "logout")
output, err := cmd.CombinedOutput()

require.NoError(t, err, "lstk logout failed: %s", output)
Expand All @@ -44,7 +44,7 @@ func TestLogoutCommandSucceedsWhenNoToken(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()

cmd := exec.CommandContext(ctx, "../../bin/lstk", "logout")
cmd := exec.CommandContext(ctx, binaryPath(), "logout")
output, err := cmd.CombinedOutput()

// Should succeed even if no token
Expand Down
8 changes: 8 additions & 0 deletions test/integration/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,19 @@ package integration_test

import (
"context"
"runtime"
"testing"

"github.com/docker/docker/client"
)

func binaryPath() string {
if runtime.GOOS == "windows" {
return "../../bin/lstk.exe"
}
return "../../bin/lstk"
}

var dockerClient *client.Client
var dockerAvailable bool

Expand Down
8 changes: 4 additions & 4 deletions test/integration/start_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func TestStartCommandSucceedsWithValidToken(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
defer cancel()

cmd := exec.CommandContext(ctx, "../../bin/lstk", "start")
cmd := exec.CommandContext(ctx, binaryPath(), "start")
cmd.Env = append(os.Environ(), "LOCALSTACK_AUTH_TOKEN="+authToken)
output, err := cmd.CombinedOutput()

Expand All @@ -63,7 +63,7 @@ func TestStartCommandTriggersLoginWithoutToken(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
defer cancel()

cmd := exec.CommandContext(ctx, "../../bin/lstk", "start")
cmd := exec.CommandContext(ctx, binaryPath(), "start")
cmd.Env = envWithoutAuthToken()

// Capture output asynchronously
Expand Down Expand Up @@ -108,7 +108,7 @@ func TestStartCommandSucceedsWithKeyringToken(t *testing.T) {
defer cancel()

// Run without LOCALSTACK_AUTH_TOKEN should use keyring
cmd := exec.CommandContext(ctx, "../../bin/lstk", "start")
cmd := exec.CommandContext(ctx, binaryPath(), "start")
cmd.Env = envWithoutAuthToken()
output, err := cmd.CombinedOutput()

Expand All @@ -127,7 +127,7 @@ func TestStartCommandFailsWithInvalidToken(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
defer cancel()

cmd := exec.CommandContext(ctx, "../../bin/lstk", "start")
cmd := exec.CommandContext(ctx, binaryPath(), "start")
cmd.Env = append(os.Environ(), "LOCALSTACK_AUTH_TOKEN=invalid-token")
output, err := cmd.CombinedOutput()

Expand Down
Loading