2022-04-14 01:27:39 +00:00
|
|
|
package cli
|
|
|
|
|
|
|
|
import (
|
2022-05-02 20:07:15 +00:00
|
|
|
"math"
|
2022-04-14 01:27:39 +00:00
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/MarvinJWendt/testza"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestProfileResolution(t *testing.T) {
|
2022-05-02 20:07:15 +00:00
|
|
|
ctx, err := InitCLI()
|
|
|
|
testza.AssertNoError(t, err)
|
|
|
|
|
|
|
|
resolver := NewDependencyResolver(ctx.APIClient)
|
2022-04-14 01:27:39 +00:00
|
|
|
|
|
|
|
resolved, err := (&Profile{
|
|
|
|
Name: DefaultProfileName,
|
|
|
|
Mods: map[string]ProfileMod{
|
|
|
|
"RefinedPower": {
|
|
|
|
Version: "3.0.9",
|
2022-05-02 20:07:15 +00:00
|
|
|
Enabled: true,
|
2022-04-14 01:27:39 +00:00
|
|
|
},
|
|
|
|
},
|
2022-05-02 20:07:15 +00:00
|
|
|
}).Resolve(resolver, nil, math.MaxInt)
|
2022-04-14 01:27:39 +00:00
|
|
|
|
|
|
|
testza.AssertNoError(t, err)
|
|
|
|
testza.AssertNotNil(t, resolved)
|
2022-05-02 20:07:15 +00:00
|
|
|
testza.AssertLen(t, resolved, 4)
|
2022-04-14 01:27:39 +00:00
|
|
|
|
|
|
|
_, err = (&Profile{
|
|
|
|
Name: DefaultProfileName,
|
|
|
|
Mods: map[string]ProfileMod{
|
|
|
|
"RefinedPower": {
|
|
|
|
Version: "3.0.9",
|
2022-05-02 20:07:15 +00:00
|
|
|
Enabled: true,
|
2022-04-14 01:27:39 +00:00
|
|
|
},
|
|
|
|
"RefinedRDLib": {
|
|
|
|
Version: "1.0.6",
|
2022-05-02 20:07:15 +00:00
|
|
|
Enabled: true,
|
2022-04-14 01:27:39 +00:00
|
|
|
},
|
|
|
|
},
|
2022-05-02 20:07:15 +00:00
|
|
|
}).Resolve(resolver, nil, math.MaxInt)
|
2022-04-14 01:27:39 +00:00
|
|
|
|
2022-05-02 20:31:23 +00:00
|
|
|
testza.AssertEqual(t, "failed resolving profile dependencies: failed resolving dependencies. requires different versions of RefinedRDLib", err.Error())
|
2022-04-14 01:27:39 +00:00
|
|
|
|
|
|
|
_, err = (&Profile{
|
|
|
|
Name: DefaultProfileName,
|
|
|
|
Mods: map[string]ProfileMod{
|
|
|
|
"ThisModDoesNotExist$$$": {
|
|
|
|
Version: ">0.0.0",
|
2022-05-02 20:07:15 +00:00
|
|
|
Enabled: true,
|
2022-04-14 01:27:39 +00:00
|
|
|
},
|
|
|
|
},
|
2022-05-02 20:07:15 +00:00
|
|
|
}).Resolve(resolver, nil, math.MaxInt)
|
2022-04-14 01:27:39 +00:00
|
|
|
|
|
|
|
testza.AssertEqual(t, "failed resolving profile dependencies: failed resolving dependency: ThisModDoesNotExist$$$", err.Error())
|
|
|
|
}
|