|
18 | 18 | package main |
19 | 19 |
|
20 | 20 | import ( |
21 | | - "reflect" |
22 | | - "testing" |
| 21 | + "context" |
| 22 | + "reflect" |
| 23 | + "testing" |
| 24 | + |
| 25 | + "github.com/apache/beam/sdks/v2/go/container/tools" |
23 | 26 | ) |
24 | 27 |
|
25 | 28 | func TestBuildOptionsEmpty(t *testing.T) { |
26 | | - dir := "test/empty" |
27 | | - metaOptions, err := LoadMetaOptions(dir) |
28 | | - if err != nil { |
29 | | - t.Fatalf("Got error %v running LoadMetaOptions", err) |
30 | | - } |
31 | | - if metaOptions != nil { |
32 | | - t.Fatalf("LoadMetaOptions(%v) = %v, want nil", dir, metaOptions) |
33 | | - } |
| 29 | + ctx, logger := context.Background(), &tools.Logger{} |
| 30 | + dir := "test/empty" |
| 31 | + metaOptions, err := LoadMetaOptions(ctx, logger, dir) |
| 32 | + if err != nil { |
| 33 | + t.Fatalf("Got error %v running LoadMetaOptions", err) |
| 34 | + } |
| 35 | + if metaOptions != nil { |
| 36 | + t.Fatalf("LoadMetaOptions(%v) = %v, want nil", dir, metaOptions) |
| 37 | + } |
34 | 38 |
|
35 | | - javaOptions := BuildOptions(metaOptions) |
36 | | - if len(javaOptions.JavaArguments) != 0 || len(javaOptions.Classpath) != 0 || len(javaOptions.Properties) != 0 { |
37 | | - t.Errorf("BuildOptions(%v) = %v, want nil", metaOptions, javaOptions) |
38 | | - } |
| 39 | + javaOptions := BuildOptions(ctx, logger, metaOptions) |
| 40 | + if len(javaOptions.JavaArguments) != 0 || len(javaOptions.Classpath) != 0 || len(javaOptions.Properties) != 0 { |
| 41 | + t.Errorf("BuildOptions(%v) = %v, want nil", metaOptions, javaOptions) |
| 42 | + } |
39 | 43 | } |
40 | 44 |
|
41 | 45 | func TestBuildOptionsDisabled(t *testing.T) { |
42 | | - metaOptions, err := LoadMetaOptions("test/disabled") |
43 | | - if err != nil { |
44 | | - t.Fatalf("Got error %v running LoadMetaOptions", err) |
45 | | - } |
| 46 | + ctx, logger := context.Background(), &tools.Logger{} |
| 47 | + metaOptions, err := LoadMetaOptions(ctx, logger, "test/disabled") |
| 48 | + if err != nil { |
| 49 | + t.Fatalf("Got error %v running LoadMetaOptions", err) |
| 50 | + } |
46 | 51 |
|
47 | | - javaOptions := BuildOptions(metaOptions) |
48 | | - if len(javaOptions.JavaArguments) != 0 || len(javaOptions.Classpath) != 0 || len(javaOptions.Properties) != 0 { |
49 | | - t.Errorf("BuildOptions(%v) = %v, want nil", metaOptions, javaOptions) |
50 | | - } |
| 52 | + javaOptions := BuildOptions(ctx, logger, metaOptions) |
| 53 | + if len(javaOptions.JavaArguments) != 0 || len(javaOptions.Classpath) != 0 || len(javaOptions.Properties) != 0 { |
| 54 | + t.Errorf("BuildOptions(%v) = %v, want nil", metaOptions, javaOptions) |
| 55 | + } |
51 | 56 | } |
52 | 57 |
|
53 | 58 | func TestBuildOptions(t *testing.T) { |
54 | | - metaOptions, err := LoadMetaOptions("test/priority") |
55 | | - if err != nil { |
56 | | - t.Fatalf("Got error %v running LoadMetaOptions", err) |
57 | | - } |
| 59 | + ctx, logger := context.Background(), &tools.Logger{} |
| 60 | + metaOptions, err := LoadMetaOptions(ctx, logger, "test/priority") |
| 61 | + if err != nil { |
| 62 | + t.Fatalf("Got error %v running LoadMetaOptions", err) |
| 63 | + } |
58 | 64 |
|
59 | | - javaOptions := BuildOptions(metaOptions) |
60 | | - wantJavaArguments := []string{"java_args=low", "java_args=high"} |
61 | | - wantClasspath := []string{"classpath_high", "classpath_low"} |
62 | | - wantProperties := map[string]string{ |
63 | | - "priority":"high", |
64 | | - } |
65 | | - if !reflect.DeepEqual(javaOptions.JavaArguments, wantJavaArguments) { |
66 | | - t.Errorf("BuildOptions(%v).JavaArguments = %v, want %v", metaOptions, javaOptions.JavaArguments, wantJavaArguments) |
67 | | - } |
68 | | - if !reflect.DeepEqual(javaOptions.Classpath, wantClasspath) { |
69 | | - t.Errorf("BuildOptions(%v).Classpath = %v, want %v", metaOptions, javaOptions.Classpath, wantClasspath) |
70 | | - } |
71 | | - if !reflect.DeepEqual(javaOptions.Properties, wantProperties) { |
72 | | - t.Errorf("BuildOptions(%v).JavaProperties = %v, want %v", metaOptions, javaOptions.Properties, wantProperties) |
73 | | - } |
| 65 | + javaOptions := BuildOptions(ctx, logger, metaOptions) |
| 66 | + wantJavaArguments := []string{"java_args=low", "java_args=high"} |
| 67 | + wantClasspath := []string{"classpath_high", "classpath_low"} |
| 68 | + wantProperties := map[string]string{ |
| 69 | + "priority": "high", |
| 70 | + } |
| 71 | + if !reflect.DeepEqual(javaOptions.JavaArguments, wantJavaArguments) { |
| 72 | + t.Errorf("BuildOptions(%v).JavaArguments = %v, want %v", metaOptions, javaOptions.JavaArguments, wantJavaArguments) |
| 73 | + } |
| 74 | + if !reflect.DeepEqual(javaOptions.Classpath, wantClasspath) { |
| 75 | + t.Errorf("BuildOptions(%v).Classpath = %v, want %v", metaOptions, javaOptions.Classpath, wantClasspath) |
| 76 | + } |
| 77 | + if !reflect.DeepEqual(javaOptions.Properties, wantProperties) { |
| 78 | + t.Errorf("BuildOptions(%v).JavaProperties = %v, want %v", metaOptions, javaOptions.Properties, wantProperties) |
| 79 | + } |
74 | 80 | } |
0 commit comments