Files
lpm/workflow/add_repository_test.go
zeekay eebdda069a fix: resolve all golangci-lint errors
- Remove unused goPath var
- Rename unused cobra cmd params to _
- Fix empty block in state.go
- Check os.MkdirAll error in install_source.go
- Rename unused test params to _
2026-03-11 19:42:22 -07:00

63 lines
1.2 KiB
Go

// Copyright (C) 2019-2025, Lux Partners Limited. 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, _ ...interface{}) bool {
return assert.Error(t, err)
},
},
{
name: "success",
setup: func(_ mocks) {
},
wantErr: func(t assert.TestingT, err error, _ ...interface{}) 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())
})
}
}