local > lrclib, do not duplicate local, test
This commit is contained in:
parent
8d284baa4e
commit
1490e9c1e6
|
@ -336,7 +336,7 @@ func init() {
|
|||
viper.SetDefault("scanner.genreseparators", ";/,")
|
||||
viper.SetDefault("scanner.groupalbumreleases", false)
|
||||
|
||||
viper.SetDefault("agents", "lastfm,spotify,lrclib")
|
||||
viper.SetDefault("agents", "lastfm,spotify,local,lrclib")
|
||||
viper.SetDefault("lastfm.enabled", true)
|
||||
viper.SetDefault("lastfm.language", "en")
|
||||
viper.SetDefault("lastfm.apikey", "")
|
||||
|
|
|
@ -22,7 +22,18 @@ func New(ds model.DataStore) *Agents {
|
|||
if conf.Server.Agents != "" {
|
||||
order = strings.Split(conf.Server.Agents, ",")
|
||||
}
|
||||
hasLocal := false
|
||||
for _, agent := range order {
|
||||
if agent == LocalAgentName {
|
||||
hasLocal = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if !hasLocal {
|
||||
order = append(order, LocalAgentName)
|
||||
}
|
||||
|
||||
var res []Interface
|
||||
for _, name := range order {
|
||||
init, ok := Map[name]
|
||||
|
|
|
@ -39,6 +39,30 @@ var _ = Describe("Agents", func() {
|
|||
})
|
||||
})
|
||||
|
||||
Describe("Settings", func() {
|
||||
It("does not duplicate local agent", func() {
|
||||
conf.Server.Agents = LocalAgentName
|
||||
ag := New(ds)
|
||||
Expect(ag.agents).To(HaveLen(1))
|
||||
Expect(ag.agents[0].AgentName()).To(Equal(LocalAgentName))
|
||||
})
|
||||
|
||||
It("uses orders local correctly", func() {
|
||||
for _, agent := range []string{"lastfm", "spotify", "lrclib"} {
|
||||
Register(agent, func(ds model.DataStore) Interface {
|
||||
return struct {
|
||||
Interface
|
||||
}{}
|
||||
})
|
||||
}
|
||||
|
||||
conf.Server.Agents = "lastfm,spotify,local,lrclib"
|
||||
ag := New(ds)
|
||||
Expect(ag.agents).To(HaveLen(4))
|
||||
Expect(ag.agents[2].AgentName()).To(Equal(LocalAgentName))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("Agents", func() {
|
||||
var ag *Agents
|
||||
var mock *mockAgent
|
||||
|
|
Loading…
Reference in New Issue