Borg/cmd/main_test.go
google-labs-jules[bot] aaa8ab3966 fix: Resolve broken build and improve testing
This commit fixes a critical build issue where the application was being compiled as an archive instead of an executable. This was caused by the absence of a `main` package.

The following changes have been made to resolve this and improve the development process:

- A `main.go` file has been added to the root of the project to serve as the application's entry point.
- A `Taskfile.yml` has been introduced to standardize the build, run, and testing processes.
- The build process has been corrected to produce a runnable binary.
- An end-to-end test (`TestE2E`) has been added to the test suite. This test builds the application and runs it with the `--help` flag to ensure the binary is always executable, preventing similar build regressions in the future.
2025-11-01 23:55:14 +00:00

26 lines
587 B
Go

package cmd
import (
"os"
"os/exec"
"testing"
)
func TestMain(t *testing.T) {
// This is a bit of a hack, but it's the easiest way to test the main function.
// We're just making sure that the application doesn't crash when it's run.
Execute()
}
func TestE2E(t *testing.T) {
home, err := os.UserHomeDir()
if err != nil {
t.Fatalf("Failed to get user home directory: %v", err)
}
taskPath := home + "/go/bin/task"
cmd := exec.Command(taskPath, "test-e2e")
output, err := cmd.CombinedOutput()
if err != nil {
t.Fatalf("Failed to run e2e test: %v\n%s", err, output)
}
}