37 lines
1.0 KiB
Go
37 lines
1.0 KiB
Go
package tools_test
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"testing"
|
|
|
|
"github.com/krow/krow-backend/go-api/internal/authctx"
|
|
"github.com/krow/krow-backend/go-api/internal/testutil"
|
|
"github.com/krow/krow-backend/go-api/internal/tools"
|
|
)
|
|
|
|
// TestDumpToolOutput prints what each tool actually returns against the seeded
|
|
// demo tenant. Run with -v when checking that a port produces real figures
|
|
// rather than a silent zero.
|
|
func TestDumpToolOutput(t *testing.T) {
|
|
h := testutil.New(t)
|
|
admin := authctx.Identity{
|
|
UserID: "00000000-0000-0000-0000-000000000001",
|
|
OrgID: h.OrgID, Role: "admin", Email: "admin@example.test",
|
|
}
|
|
reg := tools.NewRegistry()
|
|
for _, tool := range everyTool(h.Pool) {
|
|
reg.MustRegister(tool)
|
|
}
|
|
for _, name := range reg.Names() {
|
|
res := reg.Dispatch(context.Background(),
|
|
tools.Context{Principal: admin}, name, json.RawMessage(`{"limit":3}`))
|
|
encoded, _ := json.Marshal(res.Data)
|
|
out := string(encoded)
|
|
if len(out) > 400 {
|
|
out = out[:400] + "…"
|
|
}
|
|
t.Logf("%-24s %s", name, out)
|
|
}
|
|
}
|