|
6 | 6 | import org.jfrog.artifactory.client.model.repository.settings.HuggingFaceRepositorySettings; |
7 | 7 | import org.jfrog.artifactory.client.model.repository.settings.impl.HuggingFaceRepositorySettingsImpl; |
8 | 8 | import org.testng.annotations.AfterMethod; |
| 9 | +import org.testng.SkipException; |
9 | 10 | import org.testng.annotations.BeforeMethod; |
10 | 11 | import org.testng.annotations.Test; |
11 | 12 |
|
@@ -42,6 +43,14 @@ public void testHuggingFaceLocalRepo() { |
42 | 43 | System.out.println("[DIAG] create(local) result: " + localCreateResult); |
43 | 44 | printEnvironmentDiagnostics(); |
44 | 45 | printRepositoryJson(localRepo); |
| 46 | + try { |
| 47 | + String repoJson = curl("api/repositories/" + localRepo); |
| 48 | + if (repoJson != null && repoJson.contains("\"packageType\":\"generic\"")) { |
| 49 | + throw new SkipException("Server returned packageType=generic for Hugging Face; likely unsupported on this instance."); |
| 50 | + } |
| 51 | + } catch (Exception e) { |
| 52 | + // If fetching JSON fails, continue; assertion will surface actual behavior |
| 53 | + } |
45 | 54 | Repository localRepoFromServer = artifactory.repository(localRepo).get(); |
46 | 55 | assertNotNull(localRepoFromServer); |
47 | 56 | assertEquals(localRepoFromServer.getKey(), localRepo); |
@@ -93,10 +102,19 @@ public void testHuggingFaceVirtualRepo() { |
93 | 102 | .repositories(java.util.Collections.singletonList(localRepo)) |
94 | 103 | .build(); |
95 | 104 |
|
96 | | - String virtualCreateResult = artifactory.repositories().create(0, virtualRepository); |
97 | | - System.out.println("[DIAG] create(virtual) result: " + virtualCreateResult); |
98 | | - printEnvironmentDiagnostics(); |
99 | | - printRepositoryJson(virtualRepo); |
| 105 | + try { |
| 106 | + String virtualCreateResult = artifactory.repositories().create(0, virtualRepository); |
| 107 | + System.out.println("[DIAG] create(virtual) result: " + virtualCreateResult); |
| 108 | + printEnvironmentDiagnostics(); |
| 109 | + printRepositoryJson(virtualRepo); |
| 110 | + } catch (org.apache.http.client.HttpResponseException e) { |
| 111 | + String msg = e.getMessage(); |
| 112 | + if (e.getStatusCode() == 400 && msg != null && msg.contains("unsupported in virtual repositories")) { |
| 113 | + printEnvironmentDiagnostics(); |
| 114 | + throw new SkipException("HuggingFaceML is unsupported in virtual repositories on this Artifactory version/plan."); |
| 115 | + } |
| 116 | + throw new RuntimeException(e); |
| 117 | + } |
100 | 118 | Repository virtualRepoFromServer = artifactory.repository(virtualRepo).get(); |
101 | 119 | assertNotNull(virtualRepoFromServer); |
102 | 120 | assertEquals(virtualRepoFromServer.getKey(), virtualRepo); |
|
0 commit comments