test: drop tests that grep source text instead of behaviour

These asserted on file contents rather than what the code does:
Dockerfile strings, deploy.yml YAML, CHANGELOG headings, and greps of
main.go for identifiers. Two also referenced config.docker.toml and
docker-compose.yml, which were never committed, so they could not pass
at all.

The worst compared strings.Index byte offsets in main.go to assert
startup ordering -- it would pass on code that never runs and fail on
a correct refactor that moved a line.
This commit is contained in:
sam committed 2026-07-31 01:13:16 +10:00
1 parent 4c0a06df6d
commit bc5d8dcdc9
5 files changed
-282

No files matched your search

-47
View File
@@ -6,7 +6,6 @@ import (
"fmt"
"io"
"log/slog"
"os"
"path/filepath"
"strings"
"testing"
@@ -160,42 +159,6 @@ func TestChatGenerateOptionsHonoursConfiguredMaxSteps(t *testing.T) {
}
}
func TestGatewaysStartOnlyAfterCapabilityHostAndDaemonStartup(t *testing.T) {
source, err := os.ReadFile("main.go")
if err != nil {
t.Fatal(err)
}
text := string(source)
hostStart := strings.Index(text, "capabilityHost.Start(ctx)")
daemonStart := strings.Index(text, "d.Startup(ctx)")
gatewayStart := strings.Index(text, "for _, startGateway := range startGateways")
if hostStart < 0 || daemonStart < 0 || gatewayStart < 0 {
t.Fatalf("startup markers missing: host=%d daemon=%d gateway=%d", hostStart, daemonStart, gatewayStart)
}
if gatewayStart < hostStart || gatewayStart < daemonStart {
t.Fatalf("gateway start at %d must follow host %d and daemon %d startup", gatewayStart, hostStart, daemonStart)
}
}
func TestTelegramRouterUsesRuntimeSelectableChatModel(t *testing.T) {
source, err := os.ReadFile("main.go")
if err != nil {
t.Fatal(err)
}
text := string(source)
if tgSource, err := os.ReadFile("telegram_setup.go"); err == nil {
text += string(tgSource)
}
for _, marker := range []string{
"Models = ",
"ChatModels.ActiveModel()",
} {
if !strings.Contains(text, marker) {
t.Errorf("Telegram chat model wiring missing %q", marker)
}
}
}
func TestConfiguredMCPProviderSupportsAllTransportTypes(t *testing.T) {
tests := []struct {
name string
@@ -268,16 +231,6 @@ func TestConfiguredMCPProviderSupportsAllTransportTypes(t *testing.T) {
}
}
func TestConfiguredMCPProviderPassesWorkingDirectoryToClientTransport(t *testing.T) {
source, err := os.ReadFile("main.go")
if err != nil {
t.Fatal(err)
}
if !strings.Contains(string(source), "Dir: server.WorkDir") {
t.Fatal("configured MCP client transport does not receive server.WorkDir")
}
}
func TestChatTaskWriterAdapter(t *testing.T) {
t.Parallel()
-57
View File
@@ -1,57 +0,0 @@
package main
import (
"os"
"strings"
"testing"
)
func TestArchiedImageAndComposeProvideDesktopCommanderClient(t *testing.T) {
tests := []struct {
path string
markers []string
}{
{
path: "../../Dockerfile.archied",
markers: []string{
"nodejs npm",
},
},
{
path: "../../config.docker.toml",
markers: []string{
`name = "desktop-commander"`,
`command = "npx"`,
`"@wonderwhy-er/desktop-commander@0.2.46"`,
`work_dir = "/workspace"`,
},
},
{
path: "../../docker-compose.yml",
markers: []string{
"./:/workspace",
},
},
{
path: "../../config.example.toml",
markers: []string{
"[[tools.mcp_servers]]",
`work_dir = "/path/to/workspace"`,
},
},
}
for _, test := range tests {
t.Run(test.path, func(t *testing.T) {
data, err := os.ReadFile(test.path)
if err != nil {
t.Fatal(err)
}
for _, marker := range test.markers {
if !strings.Contains(string(data), marker) {
t.Errorf("%s missing %q", test.path, marker)
}
}
})
}
}
-99
View File
@@ -1,99 +0,0 @@
package main
import (
"os"
"strings"
"testing"
)
func TestReleaseMetadataIsBuiltAndPackagedWithArchied(t *testing.T) {
dockerfile, err := os.ReadFile("../../Dockerfile.archied")
if err != nil {
t.Fatal(err)
}
for _, marker := range []string{
"ARG GATEWAY_VERSION=dev",
"ARG RUNTIME_VERSION=dev",
"-X main.gatewayVersion=${GATEWAY_VERSION}",
"-X main.runtimeVersion=${RUNTIME_VERSION}",
"COPY CHANGELOG.archied.md /usr/share/archie/CHANGELOG.archied.md",
"COPY CHANGELOG.archie.md /usr/share/archie/CHANGELOG.archie.md",
} {
if !strings.Contains(string(dockerfile), marker) {
t.Errorf("Dockerfile.archied missing %q", marker)
}
}
workflow, err := os.ReadFile("../../.gitea/workflows/deploy.yml")
if err != nil {
t.Fatal(err)
}
for _, marker := range []string{
"fetch-depth: 0",
`--points-at HEAD --list 'archied/v*'`,
`--points-at HEAD --list 'archie/v*'`,
`--build-arg GATEWAY_VERSION="$GATEWAY_VERSION"`,
`--build-arg RUNTIME_VERSION="$RUNTIME_VERSION"`,
} {
if !strings.Contains(string(workflow), marker) {
t.Errorf("deploy workflow missing %q", marker)
}
}
}
func TestChangelogsTrackGatewayAndRuntimeIndependently(t *testing.T) {
changelog, err := os.ReadFile("../../CHANGELOG.md")
if err != nil {
t.Fatal(err)
}
index := string(changelog)
for _, marker := range []string{
"CHANGELOG.archied.md",
"CHANGELOG.archie.md",
"archied/vX.Y.Z",
"archie/vX.Y.Z",
} {
if !strings.Contains(index, marker) {
t.Errorf("CHANGELOG.md missing %q", marker)
}
}
gateway, err := os.ReadFile("../../CHANGELOG.archied.md")
if err != nil {
t.Fatal(err)
}
for _, marker := range []string{"## [1.1.0] - 2026-07-27", "/help", "/provider", "/model", "MCP"} {
if !strings.Contains(string(gateway), marker) {
t.Errorf("CHANGELOG.archied.md missing %q", marker)
}
}
runtime, err := os.ReadFile("../../CHANGELOG.archie.md")
if err != nil {
t.Fatal(err)
}
if !strings.Contains(string(runtime), "## [1.1.0] - 2026-07-27") {
t.Error("CHANGELOG.archie.md missing current release section")
}
}
func TestTelegramReleaseAnnouncementsAreWiredFromDeploymentMetadata(t *testing.T) {
source, err := os.ReadFile("main.go")
if err != nil {
t.Fatal(err)
}
text := string(source)
if tgSource, err := os.ReadFile("telegram_setup.go"); err == nil {
text += string(tgSource)
}
for _, marker := range []string{
"releaseannounce.Announcer{",
`"THE GATEWAY"`,
`"THE RUNTIME"`,
"gatewayVersion",
"runtimeVersion",
"tg.ReleaseAnnouncements",
} {
if !strings.Contains(text, marker) {
t.Errorf("Telegram release announcement wiring missing %q", marker)
}
}
}
-54
View File
@@ -1,54 +0,0 @@
package main
import (
"os"
"strings"
"testing"
)
// TestChatResponderResolvesSessionsThroughRouter guards the wiring that ties
// chat history to the session lifecycle commands.
//
// The responder must resolve a session through Router.ResolveSessionKey, which
// consults the session tracker. A local channel-keyed helper agrees with the
// tracker only until /new, /branch or /resume assigns a session a generated
// id; from then on the commands and the conversation address different
// histories, so /new reported "Conversation history has been cleared" while
// the next turn still saw every earlier message.
//
// This is asserted against the source, in the style of
// internal/tools/provider/contract_test.go, because the wiring is what
// matters and it has no return value to inspect.
func TestChatResponderResolvesSessionsThroughRouter(t *testing.T) {
t.Parallel()
source, err := os.ReadFile("telegram_setup.go")
if err != nil {
t.Fatalf("read telegram_setup.go: %v", err)
}
text := string(source)
if !strings.Contains(text, "router.ResolveSessionKey(ctx, msg)") {
t.Error("the chat responder must resolve sessions via router.ResolveSessionKey, " +
"so /new, /resume, /undo and /compress act on the history the conversation reads")
}
if strings.Contains(text, "sessionKey(msg)") {
t.Error("the chat responder must not key history by channel id directly; " +
"that bypasses the session tracker and desynchronises the session commands")
}
}
// TestNoInlineSessionKeyHelper keeps the removed helper from returning. It
// looked harmless and quietly reintroduced the split namespace.
func TestNoInlineSessionKeyHelper(t *testing.T) {
t.Parallel()
source, err := os.ReadFile("main.go")
if err != nil {
t.Fatalf("read main.go: %v", err)
}
if strings.Contains(string(source), "func sessionKey(") {
t.Error("main.go redefines a local sessionKey helper; " +
"gateway.Router.ResolveSessionKey is the single session resolver")
}
}
@@ -262,31 +262,6 @@ func TestOverlay(t *testing.T) {
}
}
func TestDockerConfigOverlaysExampleConfig(t *testing.T) {
cfg, err := loadOverlay(
filepath.Join("..", "..", "..", "config.example.toml"),
filepath.Join("..", "..", "..", "config.docker.toml"),
)
if err != nil {
t.Fatal(err)
}
if cfg.Agent.Mode != "nats" {
t.Errorf("Agent.Mode: got %q, want %q", cfg.Agent.Mode, "nats")
}
if cfg.Containers.Image == "" {
t.Error("Containers.Image: want docker overlay image, got empty")
}
// bot_user and repos are not set by the docker overlay -- they must
// come from the base config, proving the overlay isn't a standalone
// config that silently drops required fields.
if cfg.BotUser == "" {
t.Error("BotUser: want value from base config.example.toml, got empty")
}
if len(cfg.Repos) == 0 {
t.Error("Repos: want repos from base config.example.toml, got none")
}
}
func TestLoadBytesDoesNotExist(t *testing.T) {
_, err := loadBytes(nil)
if err == nil {