Files
Logging-System/cli/cli_test.go
T
weichen 9c5442f06d Enable canonical versioned Go module consumption
Why: Allow consumers to download an immutable module revision without nested source checkouts or local path replacements.

Evidence: SELF package tests and the prior canonical-path rejection are recorded in the Dev dependency-workspace task card; remote consumption is replayed against the committed candidate.

Impact: Change the module identity and its Go imports while preserving API behavior. Existing historical submodule revisions remain buildable.

Refs: Versioned dependencies U1/U3; feature/dependency-workspace
2026-10-13 15:06:47 +00:00

34 lines
788 B
Go

package cli
import (
"bytes"
"net/http"
"net/http/httptest"
"strings"
"testing"
"git-ssh.u1680832.nyat.app/weichen/Logging-System.git/server"
)
func TestQueryCommand(t *testing.T) {
srv, err := server.New("", "", 100)
if err != nil {
t.Fatal(err)
}
ts := httptest.NewServer(srv.Handler())
defer ts.Close()
res, err := http.Post(ts.URL+"/v1/logs", "application/json", strings.NewReader(`{"entries":[{"level":"info","msg":"hello-cli","service":"demo"}]}`))
if err != nil {
t.Fatal(err)
}
res.Body.Close()
var out, errBuf bytes.Buffer
code := Run([]string{"query", "--addr", ts.URL, "--service", "demo"}, &out, &errBuf)
if code != 0 {
t.Fatal(errBuf.String())
}
if !strings.Contains(out.String(), "hello-cli") {
t.Fatalf("query output: %s", out.String())
}
}