-
Notifications
You must be signed in to change notification settings - Fork 2
/
evaluate_test.go
63 lines (50 loc) · 1.28 KB
/
evaluate_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package main
import (
"context"
"fmt"
"os"
"path/filepath"
"testing"
)
func TestEvaluate(t *testing.T) {
SendEvalStatus = func(ctx context.Context, es EvalStatus) {}
// Load example project
project, err := LoadProject("testdata/eval/NREL-5MW.json")
if err != nil {
t.Fatal(err)
}
// Get path to OpenFAST executable, if not found skip test
execPath, found := os.LookupEnv("OPENFAST_PATH")
if !found {
t.Skip("executable path not specified in OPENFAST_PATH environment variable")
}
// Get first case
c := project.Analysis.Cases[0]
// Get operating point, set rotor speed to zero so linearization happens immediately
op := c.OperatingPoints[0]
op.RotorSpeed = 0
// Create path to case directory
caseDir := filepath.Join("testdata/output/eval", fmt.Sprintf("Case%02d", c.ID))
// Remove case directory if it exists
err = os.RemoveAll(caseDir)
if err != nil {
t.Fatal(err)
}
// Create case directory
if err := os.MkdirAll(caseDir, 0777); err != nil {
t.Fatal(err)
}
// Create evaluate struct
eval := &Evaluate{
ExecPath: execPath,
ExecValid: true,
FilesOnly: false,
}
// Wrap app context with cancel function
ctx := context.Background()
// Evaluate operating point
err = eval.OP(ctx, project.Model, &c, &op, caseDir)
if err != nil {
t.Fatal(err)
}
}