|
1 | 1 | package io.github.typesafegithub.workflows.codegenerator.versions |
2 | 2 |
|
3 | 3 | import io.github.typesafegithub.workflows.actionbindinggenerator.domain.ActionCoords |
| 4 | +import io.github.typesafegithub.workflows.actionbindinggenerator.domain.MetadataRevision |
| 5 | +import io.github.typesafegithub.workflows.actionbindinggenerator.metadata.Input |
| 6 | +import io.github.typesafegithub.workflows.actionbindinggenerator.metadata.Metadata |
| 7 | +import io.github.typesafegithub.workflows.actionbindinggenerator.metadata.Output |
4 | 8 | import io.github.typesafegithub.workflows.codegenerator.model.Version |
5 | 9 | import io.kotest.assertions.assertSoftly |
6 | 10 | import io.kotest.core.spec.style.FunSpec |
@@ -55,24 +59,67 @@ class SuggestVersionsTest : FunSpec({ |
55 | 59 | } |
56 | 60 |
|
57 | 61 | test("New major version") { |
58 | | - assertSoftly { |
| 62 | + @Suppress("UNUSED_PARAMETER") |
| 63 | + fun ActionCoords.fetchMeta(metadataRevision: MetadataRevision): Metadata { |
| 64 | + assert(owner == "test-owner") |
| 65 | + assert(name == "test-name") |
| 66 | + return when (this.version) { |
| 67 | + "v1" -> |
| 68 | + Metadata( |
| 69 | + name = "Test", |
| 70 | + description = "Test", |
| 71 | + inputs = |
| 72 | + mapOf( |
| 73 | + "some-input" to Input(), |
| 74 | + "input-will-be-removed-in-v2" to Input(), |
| 75 | + ), |
| 76 | + outputs = |
| 77 | + mapOf( |
| 78 | + "some-outputs" to Output(), |
| 79 | + "outputs-will-be-removed-in-v2" to Output(), |
| 80 | + ), |
| 81 | + ) |
| 82 | + "v2", "v3", "v9", "v12" -> |
| 83 | + Metadata( |
| 84 | + name = "Test", |
| 85 | + description = "Test", |
| 86 | + inputs = |
| 87 | + mapOf( |
| 88 | + "some-input" to Input(), |
| 89 | + "new-input-in-v2" to Input(), |
| 90 | + ), |
| 91 | + outputs = |
| 92 | + mapOf( |
| 93 | + "some-outputs" to Output(), |
| 94 | + "new-input-in-v2" to Output(), |
| 95 | + ), |
| 96 | + ) |
| 97 | + else -> error("No mocked response for version ${this.version}") |
| 98 | + } |
| 99 | + } |
59 | 100 |
|
| 101 | + assertSoftly { |
60 | 102 | testCoords.suggestNewerVersion( |
61 | 103 | "v1".versions(), |
62 | 104 | "v1, v1.1.1, v2, v2.0.1, v3, v3.1.1".versions(), |
| 105 | + fetchMeta = ActionCoords::fetchMeta, |
63 | 106 | ) shouldBe "new version(s) available: [" + |
64 | | - "v2 ([diff](https://github.com/test-owner/test-name/compare/v1...v2#files_bucket)), " + |
65 | | - "v3 ([diff](https://github.com/test-owner/test-name/compare/v1...v3#files_bucket))]" |
| 107 | + "v2 (added inputs: [new-input-in-v2], removed inputs: [input-will-be-removed-in-v2], " + |
| 108 | + "added outputs: [new-input-in-v2], removed outputs: [outputs-will-be-removed-in-v2]), " + |
| 109 | + "v3 (added inputs: [new-input-in-v2], removed inputs: [input-will-be-removed-in-v2], " + |
| 110 | + "added outputs: [new-input-in-v2], removed outputs: [outputs-will-be-removed-in-v2])]" |
66 | 111 |
|
67 | 112 | testCoords.suggestNewerVersion( |
68 | 113 | "v2".versions(), |
69 | 114 | "v1.1.1, v2, v2.0.1, v3, v3.1.1".versions(), |
70 | | - ) shouldBe "new version(s) available: [v3 ([diff](https://github.com/test-owner/test-name/compare/v2...v3#files_bucket))]" |
| 115 | + fetchMeta = ActionCoords::fetchMeta, |
| 116 | + ) shouldBe "new version(s) available: [v3 (added inputs: [], removed inputs: [], added outputs: [], removed outputs: [])]" |
71 | 117 |
|
72 | 118 | testCoords.suggestNewerVersion( |
73 | 119 | "v9".versions(), |
74 | 120 | "v12, v12.0.1".versions(), |
75 | | - ) shouldBe "new version(s) available: [v12 ([diff](https://github.com/test-owner/test-name/compare/v9...v12#files_bucket))]" |
| 121 | + fetchMeta = ActionCoords::fetchMeta, |
| 122 | + ) shouldBe "new version(s) available: [v12 (added inputs: [], removed inputs: [], added outputs: [], removed outputs: [])]" |
76 | 123 | } |
77 | 124 | } |
78 | 125 | } |
|
0 commit comments