Initial commit on Forgejo
Some checks failed
CI and releases / Test and vet (push) Failing after 1s
CI and releases / Build release binaries (push) Has been skipped
CI and releases / Publish GitHub release (push) Has been skipped

Fresh repository history for elektrine/tarakan-client hosted at
https://git.elektrine.com/elektrine/tarakan-client.
This commit is contained in:
Maxfield Luke 2026-07-29 04:56:36 -04:00
commit 58b29a7f84
70 changed files with 12994 additions and 0 deletions

View file

@ -0,0 +1,45 @@
package app
import (
"testing"
"github.com/atomine-elektrine/tarakan-client/internal/agent"
"github.com/atomine-elektrine/tarakan-client/internal/api"
repoctx "github.com/atomine-elektrine/tarakan-client/internal/context"
)
func TestLoginCommandStartsBrowserAuthorization(t *testing.T) {
t.Setenv("XDG_CONFIG_HOME", t.TempDir())
m := NewSession(repoctx.Info{}, agent.Registry{}, agent.Provider{}, SessionOpts{
APIConfig: api.Config{BaseURL: "https://tarakan.lol"},
})
next, cmd := m.executeCommand(command{name: "login"})
got := next.(Model)
if !got.busy || got.busyStatus != "Starting browser login…" {
t.Fatalf("login state: busy=%v status=%q", got.busy, got.busyStatus)
}
if cmd == nil {
t.Fatal("/login should start the device authorization request")
}
}
func TestSuccessfulLoginUpdatesTUIConfigAndPersistsToken(t *testing.T) {
t.Setenv("XDG_CONFIG_HOME", t.TempDir())
m := NewSession(repoctx.Info{}, agent.Registry{}, agent.Provider{}, SessionOpts{
APIConfig: api.Config{BaseURL: "https://tarakan.lol"},
})
m.busy = true
m.pendingLogin = &pendingLogin{config: m.apiConfig}
next, _ := m.handleLoginPoll(loginPollMsg{
credential: api.DeviceCredential{Token: "web-issued-token"},
})
got := next.(Model)
if got.busy || got.apiConfig.Token != "web-issued-token" {
t.Fatalf("login result: busy=%v config=%#v", got.busy, got.apiConfig)
}
if saved, err := api.LoadSavedConfig(); err != nil || saved.Token != "web-issued-token" {
t.Fatalf("saved config = %#v, err = %v", saved, err)
}
}