Migrates go.mod + 22 Go imports + README + comments + generated config templates off the dead github.com/Molecule-AI/ identity onto the vanity host go.moleculesai.app, owned by us. Surfaces touched: - go.mod module declaration: github.com/Molecule-AI/molecule-cli -> go.moleculesai.app/cli - Every Go import statement under cmd/ + internal/ - README install section: rewritten to lead with the vanity install command (the previous text was migration-in-progress hedging) - Comment URLs in internal/backends/backend.go + internal/cmd/connect.go (https://github.com/Molecule-AI/molecule-cli/issues/10) -> point at git.moleculesai.app/molecule-ai/molecule-cli - Generated config templates in internal/cmd/init.go + internal/cmd/config.go: header URL updated so new users land on the live SCM - Adds internal/lint/import_path_lint_test.go — structural test that walks every *.go / *.mod / Dockerfile / *.md / *.sh / *.yml in the module and rejects future references to github.com/Molecule-AI/ or Molecule-AI/molecule-monorepo. Mutation-tested before commit. Test plan - go build ./... clean - go test ./... green (cmd/molecule + 5 internal packages + new lint gate, all pass) - TestNoLegacyGitHubImportPaths fails on injected canary, passes on clean tree (no tautology) Open dependency - go.moleculesai.app responder must be deployed before 'go install go.moleculesai.app/cli/cmd/molecule@latest' works externally. Internal builds + 'go build ./cmd/molecule' from a fresh clone work today (self-referential module path). - Responder code prepared (worker.js, vendor-portable for CF Workers / Vercel Edge); deploy tracked separately under internal#71 phase 1. Pairs with parallel migrations of plugin-gh-identity (#3) + molecule-controlplane + molecule-core under the same internal#71 sweep. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
85 lines
2.2 KiB
Go
85 lines
2.2 KiB
Go
package connect_test
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"go.moleculesai.app/cli/internal/connect"
|
|
)
|
|
|
|
func TestState_LoadMissingReturnsZero(t *testing.T) {
|
|
dir := t.TempDir()
|
|
got, err := connect.LoadState(dir, "ws-x")
|
|
if err != nil {
|
|
t.Fatalf("LoadState missing: %v", err)
|
|
}
|
|
if got.WorkspaceID != "ws-x" {
|
|
t.Errorf("WorkspaceID: got %q, want ws-x", got.WorkspaceID)
|
|
}
|
|
if got.LastSinceID != "" {
|
|
t.Errorf("LastSinceID: got %q, want empty", got.LastSinceID)
|
|
}
|
|
}
|
|
|
|
func TestState_SaveLoadRoundtrip(t *testing.T) {
|
|
dir := t.TempDir()
|
|
in := connect.State{WorkspaceID: "ws-1", LastSinceID: "act-42"}
|
|
if err := connect.SaveState(dir, in); err != nil {
|
|
t.Fatalf("SaveState: %v", err)
|
|
}
|
|
got, err := connect.LoadState(dir, "ws-1")
|
|
if err != nil {
|
|
t.Fatalf("LoadState: %v", err)
|
|
}
|
|
if got != in {
|
|
t.Errorf("roundtrip: got %+v, want %+v", got, in)
|
|
}
|
|
}
|
|
|
|
func TestState_AtomicRenameProducesNoTmp(t *testing.T) {
|
|
dir := t.TempDir()
|
|
if err := connect.SaveState(dir, connect.State{WorkspaceID: "ws-1", LastSinceID: "x"}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
entries, _ := os.ReadDir(dir)
|
|
for _, e := range entries {
|
|
if filepath.Ext(e.Name()) == ".tmp" {
|
|
t.Errorf("found leftover tmp file: %s", e.Name())
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestState_SaveRequiresWorkspaceID(t *testing.T) {
|
|
if err := connect.SaveState(t.TempDir(), connect.State{}); err == nil {
|
|
t.Error("expected error on empty WorkspaceID")
|
|
}
|
|
}
|
|
|
|
func TestState_LoadCorruptedSurfaces(t *testing.T) {
|
|
dir := t.TempDir()
|
|
if err := os.WriteFile(connect.StatePath(dir, "ws-broken"), []byte("not json"), 0o600); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
_, err := connect.LoadState(dir, "ws-broken")
|
|
if err == nil {
|
|
t.Error("expected error on corrupted file")
|
|
}
|
|
}
|
|
|
|
func TestState_FilePermissions(t *testing.T) {
|
|
dir := t.TempDir()
|
|
if err := connect.SaveState(dir, connect.State{WorkspaceID: "ws-perm", LastSinceID: "x"}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
info, err := os.Stat(connect.StatePath(dir, "ws-perm"))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
// 0o600 — owner-only read/write. Tokens may end up here in future
|
|
// state additions; lock it down from day 1.
|
|
if perm := info.Mode().Perm(); perm != 0o600 {
|
|
t.Errorf("perm: got %o, want 600", perm)
|
|
}
|
|
}
|