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
34 lines
788 B
Go
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())
|
|
}
|
|
}
|