Copilot commented on code in PR #5699: URL: https://github.com/apache/texera/pull/5699#discussion_r3408753157
########## common/workflow-core/src/test/scala/org/apache/texera/amber/core/storage/result/WorkflowResultStoreSpec.scala: ########## @@ -0,0 +1,101 @@ +/* + * 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. + */ + +package org.apache.texera.amber.core.storage.result + +import org.apache.texera.amber.core.virtualidentity.OperatorIdentity +import org.scalatest.flatspec.AnyFlatSpec + +class WorkflowResultStoreSpec extends AnyFlatSpec { + + // --------------------------------------------------------------------------- + // Fixtures + // --------------------------------------------------------------------------- + + private val opA = OperatorIdentity("op-a") + private val opB = OperatorIdentity("op-b") + + // --------------------------------------------------------------------------- + // Default state + // --------------------------------------------------------------------------- + + "WorkflowResultStore()" should "default resultInfo to Map.empty" in { + assert(WorkflowResultStore().resultInfo.isEmpty) + } + + // --------------------------------------------------------------------------- + // Custom map preserves entries + // --------------------------------------------------------------------------- + + "WorkflowResultStore(...)" should + "preserve a Map carrying multiple operator metadatas" in { Review Comment: Test description uses the nonstandard plural "metadatas"; in technical writing "metadata" is typically both singular and plural. Consider rewording to avoid the grammatical distraction. ########## common/workflow-core/src/test/scala/org/apache/texera/amber/core/storage/model/OnDatasetSpec.scala: ########## @@ -0,0 +1,104 @@ +/* + * 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. + */ + +package org.apache.texera.amber.core.storage.model + +import org.scalatest.flatspec.AnyFlatSpec + +class OnDatasetSpec extends AnyFlatSpec { + + // --------------------------------------------------------------------------- + // Test-only concrete subclass — exposes the three accessors the trait + // declares. `OnDataset` is purely a contract; the behavior to pin is + // that a value of type `OnDataset` can be constructed, that its accessors + // return the values passed in, and that pattern-matching against the + // trait works for cross-module dispatch. + // --------------------------------------------------------------------------- + + private class StubOnDataset(repo: String, hash: String, relPath: String) extends OnDataset { + override def getRepositoryName(): String = repo + override def getVersionHash(): String = hash + override def getFileRelativePath(): String = relPath + } + + // --------------------------------------------------------------------------- + // Accessor surface — return verbatim + // --------------------------------------------------------------------------- + + "OnDataset.getRepositoryName" should "return the value supplied by the concrete impl" in { + val ds: OnDataset = new StubOnDataset("my-repo", "abc123", "data/file.csv") + assert(ds.getRepositoryName() == "my-repo") + } + + "OnDataset.getVersionHash" should "return the value supplied by the concrete impl" in { + val ds: OnDataset = new StubOnDataset("my-repo", "abc123", "data/file.csv") + assert(ds.getVersionHash() == "abc123") + } + + "OnDataset.getFileRelativePath" should "return the value supplied by the concrete impl" in { + val ds: OnDataset = new StubOnDataset("my-repo", "abc123", "data/file.csv") + assert(ds.getFileRelativePath() == "data/file.csv") + } + + // --------------------------------------------------------------------------- + // Empty / unusual values are passed through unchanged + // --------------------------------------------------------------------------- + + "OnDataset accessors" should + "pass empty strings through unchanged (the trait imposes no validation)" in { + val ds: OnDataset = new StubOnDataset("", "", "") + assert(ds.getRepositoryName() == "") + assert(ds.getVersionHash() == "") + assert(ds.getFileRelativePath() == "") + } + + it should "return distinct values across two distinct implementations" in { + val a: OnDataset = new StubOnDataset("repo-a", "h-a", "p-a") + val b: OnDataset = new StubOnDataset("repo-b", "h-b", "p-b") + assert(a.getRepositoryName() != b.getRepositoryName()) + assert(a.getVersionHash() != b.getVersionHash()) + assert(a.getFileRelativePath() != b.getFileRelativePath()) + } Review Comment: This test claims to cover "two distinct implementations", but it instantiates the same StubOnDataset class twice with different constructor args. That still tests different values, but not different concrete implementations as the description states; using two separate anonymous implementations (or two stub classes) would make the test match its stated intent. ########## common/workflow-core/src/test/scala/org/apache/texera/amber/core/storage/model/OnDatasetSpec.scala: ########## @@ -0,0 +1,104 @@ +/* + * 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. + */ + +package org.apache.texera.amber.core.storage.model + +import org.scalatest.flatspec.AnyFlatSpec + +class OnDatasetSpec extends AnyFlatSpec { + + // --------------------------------------------------------------------------- + // Test-only concrete subclass — exposes the three accessors the trait + // declares. `OnDataset` is purely a contract; the behavior to pin is + // that a value of type `OnDataset` can be constructed, that its accessors + // return the values passed in, and that pattern-matching against the + // trait works for cross-module dispatch. + // --------------------------------------------------------------------------- + + private class StubOnDataset(repo: String, hash: String, relPath: String) extends OnDataset { + override def getRepositoryName(): String = repo + override def getVersionHash(): String = hash + override def getFileRelativePath(): String = relPath + } + + // --------------------------------------------------------------------------- + // Accessor surface — return verbatim + // --------------------------------------------------------------------------- + + "OnDataset.getRepositoryName" should "return the value supplied by the concrete impl" in { + val ds: OnDataset = new StubOnDataset("my-repo", "abc123", "data/file.csv") + assert(ds.getRepositoryName() == "my-repo") + } + + "OnDataset.getVersionHash" should "return the value supplied by the concrete impl" in { + val ds: OnDataset = new StubOnDataset("my-repo", "abc123", "data/file.csv") + assert(ds.getVersionHash() == "abc123") + } + + "OnDataset.getFileRelativePath" should "return the value supplied by the concrete impl" in { + val ds: OnDataset = new StubOnDataset("my-repo", "abc123", "data/file.csv") + assert(ds.getFileRelativePath() == "data/file.csv") + } + + // --------------------------------------------------------------------------- + // Empty / unusual values are passed through unchanged + // --------------------------------------------------------------------------- + + "OnDataset accessors" should + "pass empty strings through unchanged (the trait imposes no validation)" in { + val ds: OnDataset = new StubOnDataset("", "", "") + assert(ds.getRepositoryName() == "") + assert(ds.getVersionHash() == "") + assert(ds.getFileRelativePath() == "") + } + + it should "return distinct values across two distinct implementations" in { + val a: OnDataset = new StubOnDataset("repo-a", "h-a", "p-a") + val b: OnDataset = new StubOnDataset("repo-b", "h-b", "p-b") + assert(a.getRepositoryName() != b.getRepositoryName()) + assert(a.getVersionHash() != b.getVersionHash()) + assert(a.getFileRelativePath() != b.getFileRelativePath()) + } + + // --------------------------------------------------------------------------- + // Pattern-matching contract — consumers branch on `case _: OnDataset` + // --------------------------------------------------------------------------- + + "An OnDataset value" should "match the OnDataset trait via type-pattern" in { + val ds: OnDataset = new StubOnDataset("r", "h", "p") + val matched: Boolean = ds match { + case _: OnDataset => true + case _ => false + } + assert(matched) + } + + it should + "not match a different unrelated type via type-pattern (sanity check)" in { + // Asymmetry sanity: a String is NOT an OnDataset. This catches a + // bizarre regression where someone made `OnDataset` extend `AnyRef`- + // less-specific. Review Comment: The comment here is a bit misleading: in Scala, traits already extend AnyRef by default, so "made OnDataset extend AnyRef" wouldn't cause a String to match this type-pattern. If the intent is to guard against accidentally widening OnDataset to something like Any/AnyRef (e.g., by turning it into a type alias), consider updating the wording to reflect that. -- 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]
