damccorm commented on code in PR #17178: URL: https://github.com/apache/beam/pull/17178#discussion_r848810226
########## sdks/java/container/boot_test.go: ########## @@ -0,0 +1,73 @@ +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// boot is the boot code for the Java SDK harness container. It is responsible +// for retrieving staged files and invoking the JVM correctly. +package main + +import ( + "reflect" + "testing" +) + +func TestBuildOptionsEmpty(t *testing.T) { + metaOptions, err := LoadMetaOptions("test/empty") + if metaOptions != nil { + t.Errorf("Got %v for meta options, but expected nil", metaOptions) + } + if err != nil { + t.Errorf("Got error %v running LoadMetaOptions", err) + } Review Comment: 2 (related) things here: 1) Use `t.Fatalf` for errors that should stop test execution. In this case, both the err check and metaOptions check keep the rest of the test from being useful so they should be fatal. 2) Prefer ordering the err check above the metaOptions check since the metaOptions check isn't informative if we return an error. The Fatalf comment applies to the rest of the tests as well. ########## sdks/java/container/boot_test.go: ########## @@ -0,0 +1,73 @@ +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// boot is the boot code for the Java SDK harness container. It is responsible +// for retrieving staged files and invoking the JVM correctly. +package main + +import ( + "reflect" + "testing" +) + +func TestBuildOptionsEmpty(t *testing.T) { + metaOptions, err := LoadMetaOptions("test/empty") + if metaOptions != nil { + t.Errorf("Got %v for meta options, but expected nil", metaOptions) Review Comment: Nit: Prefer got/want syntax with function identification - https://github.com/golang/go/wiki/TestComments#identify-the-function So for this one: ``` dir := "test/empty" metaOptions, err := LoadMetaOptions(dir) if metaOptions != nil { t.Fatalf("LoadMetaOptions(%v) = %v, want nil", dir, metaOptions) } ``` or a more complete example below: `t.Errorf("BuildOptions(%v).JavaProperties = %v, want %v", metaOptions, javaOptions.Properties, wantProperties)` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
