Skip to content

Commit

Permalink
Add rename test
Browse files Browse the repository at this point in the history
  • Loading branch information
fmeum committed Sep 6, 2024
1 parent a0d2f2d commit 56296d8
Showing 1 changed file with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1776,4 +1776,40 @@ public void testSingleVersionOverridePatches() throws Exception {
"ccc",
InterimModule.DepSpec.fromModuleKey(ModuleKey.create("ccc", Version.parse("2.0"))));
}

@Test
public void testSingleVersionOverridePatches_failsOnRename() throws Exception {
FakeRegistry registry = registryFactory.newFakeRegistry("/foo");
ModuleFileFunction.REGISTRIES.set(differencer, ImmutableSet.of(registry.getUrl()));
ModuleKey bbb = createModuleKey("bbb", "1.0");
registry.addModule(bbb, "module(name='bbb',version='1.0')");

scratch.file("BUILD");
scratch.file(
"patch.diff",
"""
diff --git a/MODULE.bazel b/MODULE.bazel.bak
similarity index 55%
rename from MODULE.bazel
rename to MODULE.bazel.bak
index 3f855b5..949dd15 100644
""");

var moduleFileKey =
ModuleFileValue.key(
bbb,
SingleVersionOverride.create(
Version.EMPTY,
"",
ImmutableList.of(Label.parseCanonicalUnchecked("//:patch.diff")),
ImmutableList.of(),
1));
EvaluationResult<ModuleFileValue> result =
evaluator.evaluate(ImmutableList.of(moduleFileKey), evaluationContext);
assertThat(result.hasError()).isTrue();
assertThat(result.getError().getException())
.hasMessageThat()
.isEqualTo(
"error applying single_version_override patch /workspace/patch.diff to module file: Renaming is not supported when applying a patch to the single file /module/MODULE.bazel.");
}
}

0 comments on commit 56296d8

Please sign in to comment.