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
31 changes: 29 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,38 @@
.PHONY: test start build pushbuild
.PHONY: test test-it test-smoke test-in-docker dev build build-hlctl pushbuild clean

# Run unit tests
test:
go test ./...
test-all:

# Run integration tests
test-it:
go test -tags=integration ./...

# Run smoke tests
test-smoke:
go test -tags=integration ./test/smoke/...

# Run tests in Docker
test-in-docker:
docker build -f dockers/DockerTestfile -t hostlink-test --progress plain --no-cache --target run-test-stage .

# Run development server
dev:
go run ./...

# Build main binary
build:
go build -o bin/hostlink

# Build hlctl binary
build-hlctl:
go build -o bin/hlctl ./cmd/hlctl

# Build and push to remote server
pushbuild:
GOOS=linux GOARCH=amd64 go build -o hostlink . && scp -O hostlink hlink:~

# Clean build artifacts
clean:
rm -rf bin/
rm -f cmd/hlctl/hlctl-test
16 changes: 16 additions & 0 deletions cmd/hlctl/commands/root.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package commands

import (
"hostlink/version"

"github.com/urfave/cli/v3"
)

// NewApp creates the root CLI application
func NewApp() *cli.Command {
return &cli.Command{
Name: "hlctl",
Usage: "Hostlink CLI - manage tasks and agents",
Version: version.Version,
}
}
41 changes: 41 additions & 0 deletions cmd/hlctl/commands/root_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package commands

import (
"bytes"
"context"
"testing"

"hostlink/version"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestNewApp(t *testing.T) {
app := NewApp()
require.NotNil(t, app)
assert.Equal(t, "hlctl", app.Name)
assert.NotEmpty(t, app.Usage)
}

func TestAppVersion(t *testing.T) {
app := NewApp()
require.NotNil(t, app)
assert.Equal(t, version.Version, app.Version)
}

func TestAppHasHelpFlag(t *testing.T) {
app := NewApp()
require.NotNil(t, app)

var buf bytes.Buffer
app.Writer = &buf

err := app.Run(context.Background(), []string{"hlctl", "--help"})
require.NoError(t, err)

output := buf.String()
assert.Contains(t, output, "hlctl", "Help should contain app name")
assert.Contains(t, output, "Hostlink CLI", "Help should contain usage description")
assert.Contains(t, output, "USAGE", "Help should contain USAGE section")
}
15 changes: 15 additions & 0 deletions cmd/hlctl/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package main

import (
"context"
"os"

"hostlink/cmd/hlctl/commands"
)

func main() {
app := commands.NewApp()
if err := app.Run(context.Background(), os.Args); err != nil {
os.Exit(1)
}
}
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ require (
github.com/ncruces/go-strftime v0.1.9 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/urfave/cli/v3 v3.4.1 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasttemplate v1.2.2 // indirect
golang.org/x/crypto v0.38.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/urfave/cli/v3 v3.4.1 h1:1M9UOCy5bLmGnuu1yn3t3CB4rG79Rtoxuv1sPhnm6qM=
github.com/urfave/cli/v3 v3.4.1/go.mod h1:FJSKtM/9AiiTOJL4fJ6TbMUkxBXn7GO9guZqoZtpYpo=
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo=
Expand Down
Loading