Compare commits
9 commits
issue-6-ma
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 668ef72dd6 | |||
|
|
74452c80e8 | ||
| 10c6aecd3e | |||
|
|
a5ca86c023 | ||
|
|
c524d8c139 | ||
| e72ef6ae87 | |||
|
|
dc891ae1c4 | ||
|
|
5515215947 | ||
|
|
8191bcc224 |
11 changed files with 36 additions and 126 deletions
17
.gitignore
vendored
17
.gitignore
vendored
|
|
@ -4,25 +4,24 @@
|
||||||
*.dll
|
*.dll
|
||||||
*.so
|
*.so
|
||||||
*.dylib
|
*.dylib
|
||||||
test
|
|
||||||
test.exe
|
|
||||||
test.test
|
|
||||||
|
|
||||||
# Test binary
|
# Test binary
|
||||||
*.test
|
*.test
|
||||||
|
|
||||||
# Output of the go coverage
|
# Output of the go coverage tool
|
||||||
profile.out
|
*.out
|
||||||
|
|
||||||
# Go build directory
|
# Dependency directories
|
||||||
vendor/
|
vendor/
|
||||||
|
|
||||||
# Binary directory
|
# Go build cache
|
||||||
bin/
|
$(GOPATH)/pkg/
|
||||||
|
|
||||||
|
# Build artifacts
|
||||||
|
build/
|
||||||
|
|
||||||
# IDE
|
# IDE
|
||||||
.idea/
|
.idea/
|
||||||
.vscode/
|
.vscode/
|
||||||
*.swp
|
*.swp
|
||||||
*.swo
|
*.swo
|
||||||
*~
|
|
||||||
|
|
|
||||||
17
Makefile
Normal file
17
Makefile
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
.PHONY: build run test clean
|
||||||
|
|
||||||
|
APP_NAME := testbed2
|
||||||
|
BUILD_DIR := build
|
||||||
|
|
||||||
|
build:
|
||||||
|
go build -o $(BUILD_DIR)/$(APP_NAME) .
|
||||||
|
|
||||||
|
run: build
|
||||||
|
./$(BUILD_DIR)/$(APP_NAME)
|
||||||
|
|
||||||
|
test:
|
||||||
|
go test ./...
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf $(BUILD_DIR)
|
||||||
|
go clean -cache
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"github.com/marmaduke/testbed2/pkg/cli"
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
if err := cli.Run(os.Args[1:]); err != nil {
|
|
||||||
fmt.Fprintf(os.Stderr, "error: %v\n", err)
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
0
cmd/testbed2/.gitkeep
Normal file
0
cmd/testbed2/.gitkeep
Normal file
|
|
@ -1,15 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"github.com/marmaduke/testbed2/pkg/cli"
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
if err := cli.Run(os.Args[1:]); err != nil {
|
|
||||||
fmt.Fprintf(os.Stderr, "error: %v\n", err)
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
2
go.mod
2
go.mod
|
|
@ -1,3 +1,3 @@
|
||||||
module github.com/marmaduke/testbed2
|
module github.com/marmaduke/testbed2
|
||||||
|
|
||||||
go 1.21
|
go 1.24
|
||||||
|
|
|
||||||
0
internal/.gitkeep
Normal file
0
internal/.gitkeep
Normal file
3
main.go
Normal file
3
main.go
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
func main() {}
|
||||||
7
main_test.go
Normal file
7
main_test.go
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
|
func TestModule(t *testing.T) {
|
||||||
|
// Basic test to verify module initialization
|
||||||
|
}
|
||||||
|
|
@ -1,25 +0,0 @@
|
||||||
// Package cli provides the core CLI functionality.
|
|
||||||
package cli
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Run executes the CLI with the given arguments.
|
|
||||||
func Run(args []string) error {
|
|
||||||
if len(args) == 0 {
|
|
||||||
fmt.Println("testbed2 CLI")
|
|
||||||
fmt.Println("Usage: testbed2 <command>")
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
switch args[0] {
|
|
||||||
case "help", "--help", "-h":
|
|
||||||
fmt.Println("Available commands:")
|
|
||||||
fmt.Println(" help Show this help message")
|
|
||||||
default:
|
|
||||||
return fmt.Errorf("unknown command: %s", args[0])
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
@ -1,61 +0,0 @@
|
||||||
package cli
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"os"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestRunNoArgs(t *testing.T) {
|
|
||||||
oldStdout := os.Stdout
|
|
||||||
_, w, _ := os.Pipe()
|
|
||||||
os.Stdout = w
|
|
||||||
|
|
||||||
err := Run([]string{})
|
|
||||||
|
|
||||||
w.Close()
|
|
||||||
os.Stdout = oldStdout
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("unexpected error: %v", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestRunHelp(t *testing.T) {
|
|
||||||
oldStdout := os.Stdout
|
|
||||||
_, w, _ := os.Pipe()
|
|
||||||
os.Stdout = w
|
|
||||||
|
|
||||||
err := Run([]string{"help"})
|
|
||||||
|
|
||||||
w.Close()
|
|
||||||
os.Stdout = oldStdout
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("unexpected error: %v", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestRunUnknownCommand(t *testing.T) {
|
|
||||||
err := Run([]string{"unknown"})
|
|
||||||
if err == nil {
|
|
||||||
t.Fatal("expected error for unknown command")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestRunOutput(t *testing.T) {
|
|
||||||
oldStdout := os.Stdout
|
|
||||||
r, w, _ := os.Pipe()
|
|
||||||
os.Stdout = w
|
|
||||||
|
|
||||||
_ = Run([]string{})
|
|
||||||
|
|
||||||
w.Close()
|
|
||||||
os.Stdout = oldStdout
|
|
||||||
|
|
||||||
buf := new(bytes.Buffer)
|
|
||||||
_, _ = buf.ReadFrom(r)
|
|
||||||
if buf.Len() == 0 {
|
|
||||||
t.Fatal("expected output")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Reference in a new issue