Skip to content

Commit d45b145

Browse files
Merge pull request #110 from nextmv-io/merschformann/region-allocation
Adds Region Allocation apps
2 parents ff854a6 + bc05fe1 commit d45b145

73 files changed

Lines changed: 10986 additions & 43 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.DS_Store

-6 KB
Binary file not shown.

.nextmv/golden/python-ortools-region-allocation/inputs/input.json

Lines changed: 1956 additions & 0 deletions
Large diffs are not rendered by default.

.nextmv/golden/python-ortools-region-allocation/inputs/input.json.golden

Lines changed: 2171 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package mip
2+
3+
import (
4+
"os"
5+
"testing"
6+
7+
"github.com/nextmv-io/sdk/golden"
8+
)
9+
10+
func TestMain(m *testing.M) {
11+
code := m.Run()
12+
os.Exit(code)
13+
}
14+
15+
func TestGolden(t *testing.T) {
16+
golden.FileTests(
17+
t,
18+
"inputs",
19+
golden.Config{
20+
Args: []string{
21+
"-duration",
22+
"30",
23+
},
24+
TransientFields: []golden.TransientField{
25+
{
26+
Key: "$.statistics.result.duration",
27+
Replacement: golden.StableFloat,
28+
},
29+
{
30+
Key: "$.statistics.run.duration",
31+
Replacement: golden.StableFloat,
32+
},
33+
{
34+
Key: "$.options.output",
35+
Replacement: "output.json",
36+
},
37+
{
38+
Key: "$.options.input",
39+
Replacement: "input.json",
40+
},
41+
},
42+
ExecutionConfig: &golden.ExecutionConfig{
43+
Command: "python3",
44+
Args: []string{"../../../python-ortools-region-allocation/main.py"},
45+
InputFlag: "-input",
46+
OutputFlag: "-output",
47+
},
48+
},
49+
)
50+
}

.nextmv/readme/README.md

Lines changed: 14 additions & 0 deletions

.nextmv/readme/main_test.go

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
package mip
22

33
import (
4+
"flag"
5+
"fmt"
46
"os"
7+
"regexp"
58
"slices"
69
"strings"
710
"testing"
@@ -10,6 +13,11 @@ import (
1013
"gopkg.in/yaml.v2"
1114
)
1215

16+
// filter is a flag to filter the tests to run by name. Allows regex
17+
// matching. For example, to run all tests that start with "python-" use
18+
// -filter='python-.*.'.
19+
var filter = flag.String("filter", "", "filter tests by name")
20+
1321
func TestMain(m *testing.M) {
1422
code := m.Run()
1523
os.Exit(code)
@@ -67,6 +75,16 @@ func TestGolden(t *testing.T) {
6775
{Regex: `xpress\.init\(.*\)`, Replacement: `xpress.init("path/to/xpress")`},
6876
}
6977

78+
// Use the filter flag to filter the tests to run
79+
var regex *regexp.Regexp
80+
if *filter != "" {
81+
regex, err = regexp.Compile(*filter)
82+
if err != nil {
83+
fmt.Println("Error compiling filter regex:", err)
84+
return
85+
}
86+
}
87+
7088
// Run all readme tests
7189
dirs, err := os.ReadDir(".")
7290
if err != nil {
@@ -101,10 +119,14 @@ func TestGolden(t *testing.T) {
101119
if scriptConfig.Skip {
102120
continue
103121
}
104-
t.Run(app+"/"+script, func(t *testing.T) {
122+
t.Run("readme", func(t *testing.T) {
123+
testName := app + "/" + script
124+
if regex != nil && !regex.MatchString(testName) {
125+
t.Skipf("skipping test %s", testName)
126+
}
105127
golden.BashTestFile(
106128
t,
107-
app+"/"+script,
129+
testName,
108130
golden.BashConfig{
109131
DisplayStdout: !scriptConfig.Silent,
110132
WorkingDir: "../../" + app,
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pip3 install -r requirements.txt

.nextmv/readme/python-ortools-region-allocation/0.sh.golden

Whitespace-only changes.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
python3 main.py -input input.json -output output.json \
2+
-duration 30 -provider scip

.nextmv/readme/python-ortools-region-allocation/1.sh.golden

Whitespace-only changes.

0 commit comments

Comments
 (0)