gnodet-bot commented on code in PR #2224:
URL: https://github.com/apache/maven-resolver/pull/2224#discussion_r4357000579


##########
maven-resolver-api/src/test/java/org/eclipse/aether/repository/RepositoryUriUtilsTest.java:
##########
@@ -0,0 +1,144 @@
+/*
+ * 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.eclipse.aether.repository;
+
+import java.net.URI;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+/**
+ * Tests for {@link RepositoryUriUtils#toUri(String)}, focusing on Windows 
drive-letter handling.
+ * These tests exercise the string-parsing logic and run on all platforms.
+ */
+public class RepositoryUriUtilsTest {
+
+    /**
+     * A plain Windows path with an uppercase drive letter must produce a 
{@code file:} URI
+     * whose path starts with the drive letter, not a relative path missing 
the drive.
+     */
+    @Test
+    void windowsUppercaseDriveLetterPreserved() {
+        URI uri = RepositoryUriUtils.toUri("C:\\Users\\foo\\repo");

Review Comment:
   πŸ”§ **Nit β€” Cross-platform test coverage gap**: `RepositoryUriUtilsTest` runs 
on all platforms (no `@EnabledOnOs` annotation), but the three Windows-path 
tests call `toUri("C:\\Users\\foo\\repo")` on Linux, where 
`Paths.get("C:\\Users\\foo\\repo")` treats the input as a *relative* path 
(backslash is not a path separator on Linux). The resulting URI resolves 
against CWD and looks like `file:///cwd/C%3A%5CUsers%5Cfoo%5Crepo`. The 
`assertContainsDriveLetter` helper then finds `C:` in the encoded path and 
reports a pass β€” but it’s testing the wrong code path entirely.
   
   Two options:
   1. Add `@EnabledOnOs(OS.WINDOWS)` to `windowsUppercaseDriveLetterPreserved`, 
`windowsLowercaseDriveLetterPreserved`, and `windowsDriveLetterForwardSlash`.
   2. Assert the specific output rather than using `assertContainsDriveLetter`, 
so the assertion fails fast on Linux when the wrong branch is taken.
   
   The `fileUrlWithWindowsDriveLetter()` and 
`fileUrlTripleSlashWithWindowsDriveLetter()` tests use `file:` URLs (not bare 
Windows paths) and are correct to run on all platforms.



-- 
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]

Reply via email to