mirror of
https://github.com/luxfi/lpm.git
synced 2026-10-30 16:20:57 +00:00
Modules declare go 1.27.1 and the build images follow. go fix applied the modernizers, and the repository lookup is now a generic method on DiskRepository; omitzero is not applied, since it changes what the JSON says. Co-authored-by: Hanzo Dev <[email protected]>
63 lines
1.2 KiB
Go
63 lines
1.2 KiB
Go
// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package workflow
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/luxfi/lpm/state"
|
|
)
|
|
|
|
func TestAddRepositoryExecute(t *testing.T) {
|
|
type mocks struct {
|
|
sourcesList map[string]*state.SourceInfo
|
|
}
|
|
tests := []struct {
|
|
name string
|
|
setup func(mocks)
|
|
wantErr assert.ErrorAssertionFunc
|
|
}{
|
|
{
|
|
name: "already exists",
|
|
setup: func(mocks mocks) {
|
|
mocks.sourcesList["alias"] = nil
|
|
},
|
|
wantErr: func(t assert.TestingT, err error, _ ...any) bool {
|
|
return assert.Error(t, err)
|
|
},
|
|
},
|
|
{
|
|
name: "success",
|
|
setup: func(_ mocks) {
|
|
},
|
|
wantErr: func(t assert.TestingT, err error, _ ...any) bool {
|
|
return assert.Nil(t, err)
|
|
},
|
|
},
|
|
}
|
|
|
|
for _, test := range tests {
|
|
t.Run(test.name, func(t *testing.T) {
|
|
sourcesList := make(map[string]*state.SourceInfo)
|
|
|
|
test.setup(mocks{
|
|
sourcesList: sourcesList,
|
|
})
|
|
|
|
wf := NewAddRepository(
|
|
AddRepositoryConfig{
|
|
SourcesList: sourcesList,
|
|
Alias: "alias",
|
|
URL: "url",
|
|
Branch: "master",
|
|
},
|
|
)
|
|
|
|
test.wantErr(t, wf.Execute())
|
|
})
|
|
}
|
|
}
|