-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathruntime_test.go
More file actions
69 lines (61 loc) · 2.68 KB
/
Copy pathruntime_test.go
File metadata and controls
69 lines (61 loc) · 2.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package main
import (
"reflect"
"testing"
tea "github.com/charmbracelet/bubbletea"
)
func TestParseRuntimeTargetsFiltersUnsupportedAndUnknownSchema(t *testing.T) {
got := parseRuntimeTargets([]byte(`[
{"schemaVersion":1,"name":"z-local","label":"Z local","applicable":true},
{"schemaVersion":1,"name":"unsupported","applicable":false},
{"schemaVersion":2,"name":"future","applicable":true},
{"schemaVersion":1,"name":"a-local","label":"A local","applicable":true}
]`))
if len(got) != 2 || got[0].Name != "a-local" || got[1].Name != "z-local" {
t.Fatalf("unexpected targets: %#v", got)
}
}
func TestRuntimeFacetAndSelection(t *testing.T) {
targets := []runtimeTarget{{Name: "local-qwen", Label: "Local Qwen", Applicable: true}}
f := runtimeFacet("R", targets)
if !reflect.DeepEqual(f.values, []string{"hosted", "local-qwen"}) {
t.Fatalf("runtime values = %#v", f.values)
}
m := model{runtimeTargets: targets, sel: map[string]string{"runtime": "local-qwen"}}
target, ok := m.selectedRuntime()
if !ok || target.Name != "local-qwen" || m.runtimeValueLabel(target.Name) != "Local Qwen" {
t.Fatalf("selected target = %#v, %v", target, ok)
}
}
func TestRuntimeLaunchArgvOwnsProfileAndThinking(t *testing.T) {
got := runtimeLaunchArgv("/bin/atyrode", "local-qwen", "high",
[]string{"--profile", "cloud", "--config=old.yml", "--resume"}, "hello")
want := []string{"/bin/atyrode", "runtime", "run", "local-qwen", "--", "--thinking", "high", "--resume", "hello"}
if !reflect.DeepEqual(got, want) {
t.Fatalf("argv = %#v; want %#v", got, want)
}
}
func TestRuntimeStatusLine(t *testing.T) {
if got := (runtimeTarget{Healthy: true}).statusLine(); got != "ready" {
t.Fatalf("healthy status = %q", got)
}
if got := (runtimeTarget{EstimatedDiskBytes: 40 * 1024 * 1024 * 1024}).statusLine(); got != "downloads on first launch · about 40 GiB" {
t.Fatalf("first-launch status = %q", got)
}
}
func TestLocalRuntimeHidesHostedDialsAndLaunchesWithoutCatalog(t *testing.T) {
targets := []runtimeTarget{{Name: "local-qwen", Label: "Local Qwen", Applicable: true}}
facets := append([]facet{runtimeFacet("R", targets)}, facetDefs(defaultGlyphs())...)
sel := defaultSel()
sel["runtime"] = "local-qwen"
m := model{runtimeTargets: targets, facets: facets, sel: sel, generated: map[string][]string{}}
visible := m.visibleFacets()
if len(visible) != 2 || visible[0].key != "runtime" || visible[1].key != "thinking" {
t.Fatalf("local facets = %#v", visible)
}
next, cmd := m.Update(tea.KeyMsg{Type: tea.KeyEnter})
got := next.(model)
if got.launchRuntime != "local-qwen" || got.genConfig != "" || cmd == nil {
t.Fatalf("local enter: target=%q config=%q quit=%v", got.launchRuntime, got.genConfig, cmd != nil)
}
}