Artifact 9b54523a6dcc125ca11c2d607b3a9e8c74b1e689e6792959525f3d7f4adab007:
- File
leaf/agent/serve_http_test.go
— part of check-in
[38efed7a12]
at
2026-08-12 20:50:57
on branch main
— chore(deps): migrate to go-libfossil v0.9.0 (#195)
* chore(deps): migrate to go-libfossil v0.9.0 (renamed module path)
- import path danmestas/libfossil → danmestas/go-libfossil everywhere - CloneOpts.ProjectCode removed upstream; assert via CloneResult instead - Timeline now takes TimelineOpts (cursor pagination, newest-first) - testutil.HasFossil removed; check FossilBinary() != ""
* ci: retrigger checks
---------
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> (user: [email protected], size: 1596) [annotate] [blame] [check-ins using]
package agent import ( "context" "io" "net" "net/http" "strings" "testing" "time" libfossil "github.com/danmestas/go-libfossil" _ "github.com/danmestas/go-libfossil/db/driver/modernc" "github.com/danmestas/go-libfossil/simio" ) func TestServeHTTPHealthz(t *testing.T) { r := newTestRepo(t) transport := &mockTransport{} addr := freeAddr(t) a := NewFromParts(Config{ RepoPath: r.Path(), ServeHTTPAddr: addr, Clock: simio.RealClock{}, }, r, transport, "test-project", "test-server") if err := a.Start(); err != nil { t.Fatal(err) } defer a.Stop() time.Sleep(100 * time.Millisecond) resp, err := http.Get("http://" + addr + "/healthz") if err != nil { t.Fatal(err) } defer resp.Body.Close() if resp.StatusCode != http.StatusOK { t.Fatalf("healthz: got status %d, want 200", resp.StatusCode) } body, err := io.ReadAll(resp.Body) if err != nil { t.Fatal(err) } if !strings.Contains(string(body), "ok") { t.Fatalf("healthz: body %q does not contain 'ok'", body) } } func freeAddr(t *testing.T) string { t.Helper() ln, err := net.Listen("tcp", "127.0.0.1:0") if err != nil { t.Fatal(err) } addr := ln.Addr().String() ln.Close() return addr } func newTestRepo(t *testing.T) *libfossil.Repo { t.Helper() path := t.TempDir() + "/test.fossil" r, err := libfossil.Create(path, libfossil.CreateOpts{User: "test"}) if err != nil { t.Fatal(err) } t.Cleanup(func() { r.Close() }) return r } type mockTransport struct{} func (m *mockTransport) RoundTrip(_ context.Context, _ []byte) ([]byte, error) { return []byte{}, nil }