feat(agent): job runner, compose override executor and swarm executor (#7)

This commit is contained in:
2026-10-12 18:45:44 +02:00
parent 32c30194c4
commit e313365686
18 changed files with 1617 additions and 165 deletions
+38
View File
@@ -0,0 +1,38 @@
package updater
import (
"context"
"errors"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestResolver(t *testing.T) {
const d = "sha256:d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1"
auth := &RegistryAuth{byHost: map[string]string{"gitea.shcizo.se": "enc-gitea"}}
t.Run("resolves tag with registry auth", func(t *testing.T) {
dist := &fakeDist{digest: d}
got, err := NewResolver(dist, auth).Resolve(context.Background(), "gitea.shcizo.se/shcizo/slusk:1.4")
require.NoError(t, err)
assert.Equal(t, "gitea.shcizo.se/shcizo/slusk:1.4@"+d, got)
assert.Equal(t, []string{"gitea.shcizo.se/shcizo/slusk:1.4"}, dist.refs)
assert.Equal(t, []string{"enc-gitea"}, dist.auths)
})
t.Run("digest or missing tag is refused without asking the daemon", func(t *testing.T) {
for _, ref := range []string{"repo@sha256:x", "repo:1@sha256:x", "repo"} {
dist := &fakeDist{digest: d}
_, err := NewResolver(dist, nil).Resolve(context.Background(), ref)
assert.Error(t, err, ref)
assert.Empty(t, dist.refs)
}
})
t.Run("daemon error is wrapped", func(t *testing.T) {
cause := errors.New("unauthorized")
_, err := NewResolver(&fakeDist{err: cause}, nil).Resolve(context.Background(), "repo:1")
assert.ErrorIs(t, err, cause)
assert.ErrorContains(t, err, "repo:1")
})
}