mirror of
https://github.com/hanzo-git/runner.git
synced 2026-10-30 19:33:27 +00:00
Native runner: module github.com/hanzo-git/runner, wire proto github.com/hanzo-git/actions-proto-go, command git-runner, GIT_* env, git expr context, git_* task-context keys, ghcr.io/hanzoai/runner-ubuntu job images. Derived work — upstream attribution + MIT terms in NOTICE/LICENSE. Co-authored-by: Hanzo Dev <[email protected]>
52 lines
1.3 KiB
Go
52 lines
1.3 KiB
Go
// Copyright 2026 The Git Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package config
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestSaveAndLoadRegistration(t *testing.T) {
|
|
file := filepath.Join(t.TempDir(), ".runner")
|
|
|
|
reg := &Registration{
|
|
ID: 42,
|
|
UUID: "the-uuid",
|
|
Name: "runner",
|
|
Token: "the-token",
|
|
Address: "http://localhost:3000",
|
|
Labels: []string{"ubuntu:host", "ubuntu:docker://node:18"},
|
|
Ephemeral: true,
|
|
}
|
|
|
|
require.NoError(t, SaveRegistration(file, reg))
|
|
// SaveRegistration stamps the warning onto the in-memory struct
|
|
require.Equal(t, registrationWarning, reg.Warning)
|
|
|
|
loaded, err := LoadRegistration(file)
|
|
require.NoError(t, err)
|
|
|
|
// the warning is intentionally cleared on load
|
|
require.Empty(t, loaded.Warning)
|
|
loaded.Warning = reg.Warning
|
|
require.Equal(t, reg, loaded)
|
|
}
|
|
|
|
func TestLoadRegistrationMissingFile(t *testing.T) {
|
|
_, err := LoadRegistration(filepath.Join(t.TempDir(), "does-not-exist"))
|
|
require.Error(t, err)
|
|
}
|
|
|
|
func TestLoadRegistrationInvalidJSON(t *testing.T) {
|
|
file := filepath.Join(t.TempDir(), ".runner")
|
|
require.NoError(t, os.WriteFile(file, []byte("not json"), 0o600))
|
|
|
|
_, err := LoadRegistration(file)
|
|
require.Error(t, err)
|
|
}
|