chore: establish local platform baseline
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"data-terminal-cloud/internal/app"
|
||||
)
|
||||
|
||||
type applicationRunner func(context.Context, string) error
|
||||
|
||||
func run(ctx context.Context, runner applicationRunner) error {
|
||||
return runner(ctx, "worker")
|
||||
}
|
||||
|
||||
func main() {
|
||||
ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
|
||||
defer stop()
|
||||
if err := run(ctx, app.Run); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestRunWiresWorkerServiceAndPropagatesError(t *testing.T) {
|
||||
want := errors.New("synthetic worker failure")
|
||||
ctx := context.WithValue(context.Background(), struct{}{}, "request-context")
|
||||
err := run(ctx, func(gotContext context.Context, serviceName string) error {
|
||||
if gotContext != ctx || serviceName != "worker" {
|
||||
t.Fatalf("context=%v service=%q", gotContext, serviceName)
|
||||
}
|
||||
return want
|
||||
})
|
||||
if !errors.Is(err, want) {
|
||||
t.Fatalf("run error=%v", err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user