feat: add kimi a7m overlay workflow and remote43 validation
This commit is contained in:
@@ -8,6 +8,8 @@ import (
|
||||
"testing"
|
||||
|
||||
"sub2api-cn-relay-manager/internal/config"
|
||||
"sub2api-cn-relay-manager/internal/overlay"
|
||||
"sub2api-cn-relay-manager/internal/pack"
|
||||
"sub2api-cn-relay-manager/internal/provision"
|
||||
"sub2api-cn-relay-manager/internal/reconcile"
|
||||
"sub2api-cn-relay-manager/internal/store/sqlite"
|
||||
@@ -33,7 +35,7 @@ func TestExecuteWritesConfigSummaryAfterBootstrap(t *testing.T) {
|
||||
SQLiteDSN: "file:test.db?_foreign_keys=on",
|
||||
},
|
||||
}, nil
|
||||
}, nil, nil, nil, nil, nil, nil)
|
||||
}, nil, nil, nil, nil, nil, nil, nil)
|
||||
if err != nil {
|
||||
t.Fatalf("execute() returned error: %v", err)
|
||||
}
|
||||
@@ -61,7 +63,7 @@ func TestExecuteReturnsBootstrapError(t *testing.T) {
|
||||
|
||||
err := execute(context.Background(), &bytes.Buffer{}, nil, func(context.Context) (config.StartupConfig, error) {
|
||||
return config.StartupConfig{}, wantErr
|
||||
}, nil, nil, nil, nil, nil, nil)
|
||||
}, nil, nil, nil, nil, nil, nil, nil)
|
||||
if !errors.Is(err, wantErr) {
|
||||
t.Fatalf("execute() error = %v, want %v", err, wantErr)
|
||||
}
|
||||
@@ -75,7 +77,7 @@ func TestExecuteReturnsWriteError(t *testing.T) {
|
||||
Server: config.ServerConfig{ListenAddr: ":9292"},
|
||||
Database: config.DatabaseConfig{SQLiteDSN: "file:test.db"},
|
||||
}, nil
|
||||
}, nil, nil, nil, nil, nil, nil)
|
||||
}, nil, nil, nil, nil, nil, nil, nil)
|
||||
if !errors.Is(err, wantErr) {
|
||||
t.Fatalf("execute() error = %v, want %v", err, wantErr)
|
||||
}
|
||||
@@ -99,7 +101,7 @@ func TestExecuteInstallPackWritesSummary(t *testing.T) {
|
||||
HostVersion: "0.1.126",
|
||||
Providers: []sqlite.Provider{{ProviderID: "deepseek"}},
|
||||
}, nil
|
||||
}, nil, nil, nil, nil, nil)
|
||||
}, nil, nil, nil, nil, nil, nil)
|
||||
if err != nil {
|
||||
t.Fatalf("execute() install-pack error = %v", err)
|
||||
}
|
||||
@@ -134,7 +136,7 @@ func TestExecuteImportProviderWritesSummary(t *testing.T) {
|
||||
AccessStatus: provision.AccessStatusSelfServiceReady,
|
||||
Accounts: []provision.AccountImportResult{{}, {}},
|
||||
}, nil
|
||||
}, nil, nil, nil, nil)
|
||||
}, nil, nil, nil, nil, nil)
|
||||
if err != nil {
|
||||
t.Fatalf("execute() import error = %v", err)
|
||||
}
|
||||
@@ -171,7 +173,7 @@ func TestExecutePreviewProviderWritesSummary(t *testing.T) {
|
||||
"plan": {Action: provision.PreviewActionConflict},
|
||||
},
|
||||
}, nil
|
||||
}, nil, nil, nil)
|
||||
}, nil, nil, nil, nil)
|
||||
if err != nil {
|
||||
t.Fatalf("execute() preview error = %v", err)
|
||||
}
|
||||
@@ -199,7 +201,7 @@ func TestExecuteRollbackProviderWritesSummary(t *testing.T) {
|
||||
t.Fatalf("unexpected rollback request: %+v", req)
|
||||
}
|
||||
return rollbackSummary{Accounts: 2, Plans: 1, Channels: 1, Groups: 1}, nil
|
||||
}, nil, nil)
|
||||
}, nil, nil, nil)
|
||||
if err != nil {
|
||||
t.Fatalf("execute() rollback error = %v", err)
|
||||
}
|
||||
@@ -228,7 +230,7 @@ func TestExecuteReconcileProviderWritesSummary(t *testing.T) {
|
||||
t.Fatalf("unexpected reconcile request: %+v", req)
|
||||
}
|
||||
return reconcile.Result{Status: "drifted", MissingCount: 1, ExtraCount: 2, ProbeFailureCount: 1, AccessStatus: provision.AccessStatusBroken}, nil
|
||||
}, nil)
|
||||
}, nil, nil)
|
||||
if err != nil {
|
||||
t.Fatalf("execute() reconcile error = %v", err)
|
||||
}
|
||||
@@ -241,6 +243,48 @@ func TestExecuteReconcileProviderWritesSummary(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestExecuteApplyHostOverlayWritesSummary(t *testing.T) {
|
||||
var output bytes.Buffer
|
||||
applyCalled := false
|
||||
|
||||
err := execute(context.Background(), &output, []string{
|
||||
"apply-host-overlay",
|
||||
"--pack-dir", "/tmp/pack",
|
||||
"--provider-id", "kimi-a7m",
|
||||
"--host-version", "0.1.129",
|
||||
"--source-dir", "/tmp/sub2api-src",
|
||||
}, nil, nil, nil, nil, nil, nil, func(_ context.Context, req applyHostOverlayCLIRequest) (overlay.ApplyResult, error) {
|
||||
applyCalled = true
|
||||
if req.ProviderID != "kimi-a7m" || req.HostVersion != "0.1.129" {
|
||||
t.Fatalf("unexpected apply-host-overlay request: %+v", req)
|
||||
}
|
||||
return overlay.ApplyResult{
|
||||
OutputDir: "/tmp/sub2api-src-patched-sub2api-stock-v0129-kimi-a7m",
|
||||
AppliedOverlays: []pack.HostOverlay{{
|
||||
OverlayID: "sub2api-stock-v0129-kimi-a7m",
|
||||
}},
|
||||
MetadataFilePath: "/tmp/sub2api-src-patched-sub2api-stock-v0129-kimi-a7m/.sub2api-cn-relay-manager-overlay.json",
|
||||
}, nil
|
||||
}, nil)
|
||||
if err != nil {
|
||||
t.Fatalf("execute() apply-host-overlay error = %v", err)
|
||||
}
|
||||
if !applyCalled {
|
||||
t.Fatal("execute() did not invoke applyHostOverlay")
|
||||
}
|
||||
got := output.String()
|
||||
if !strings.Contains(got, "applied_overlays=1") || !strings.Contains(got, "overlay_ids=sub2api-stock-v0129-kimi-a7m") {
|
||||
t.Fatalf("execute() apply-host-overlay output = %q, want overlay summary", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseApplyHostOverlayCLIArgsRequiresSourceDir(t *testing.T) {
|
||||
_, err := parseApplyHostOverlayCLIArgs([]string{"--pack-dir", "/tmp/pack", "--provider-id", "kimi-a7m", "--host-version", "0.1.129"})
|
||||
if err == nil {
|
||||
t.Fatal("parseApplyHostOverlayCLIArgs() error = nil, want validation error")
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseInstallPackCLIArgsRequiresHostBaseURL(t *testing.T) {
|
||||
_, err := parseInstallPackCLIArgs([]string{"--pack-path", "/tmp/openai-pack.zip"})
|
||||
if err == nil {
|
||||
|
||||
Reference in New Issue
Block a user