-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathReleaseNoteGenerationTest.java
More file actions
171 lines (146 loc) · 7.34 KB
/
ReleaseNoteGenerationTest.java
File metadata and controls
171 lines (146 loc) · 7.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
package com.google.cloud;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import com.google.cloud.tools.opensource.dependencies.Bom;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.truth.Truth;
import org.junit.Test;
public class ReleaseNoteGenerationTest {
// Uses the released BOM, not the one in this repository, to avoid unnecessarily updating the
// assertions.
static final String LIBRARIES_BOM_COORDINATES = "com.google.cloud:libraries-bom:26.1.5";
@Test
public void testPreviousBom() throws Exception {
Bom bom = Bom.readBom(LIBRARIES_BOM_COORDINATES);
Bom previousBom = ReleaseNoteGeneration.previousBom(bom);
Truth.assertThat(previousBom.getCoordinates())
.isEqualTo("com.google.cloud:libraries-bom:pom:26.1.4");
}
@Test
public void testCreateVersionLessCoordinatesToKey() throws Exception {
Bom bom = Bom.readBom(LIBRARIES_BOM_COORDINATES);
ImmutableMap<String, String> versionLessCoordinatesToKey =
ReleaseNoteGeneration.createVersionLessCoordinatesToKey(bom);
// google-cloud-apigee-registry represents the libraries from google-cloud-java
// google-cloud-bigtable represents the libraries from handwritten repositories
Truth.assertThat(versionLessCoordinatesToKey)
.containsAtLeast(
"com.google.cloud:google-cloud-apigee-registry", "0.6.0",
"com.google.cloud:google-cloud-bigtable", "2.16.0");
}
@Test
public void testIsMajorVersionBump() {
assertTrue(ReleaseNoteGeneration.isMajorVersionBump("1.2.3", "2.0.1"));
assertFalse(ReleaseNoteGeneration.isMajorVersionBump("2.2.3", "2.3.1"));
}
@Test
public void testIsMinorVersionBump() {
assertTrue(ReleaseNoteGeneration.isMinorVersionBump("1.2.3", "1.3.0"));
assertFalse(ReleaseNoteGeneration.isMinorVersionBump("1.2.3", "1.2.5"));
assertFalse(ReleaseNoteGeneration.isMinorVersionBump("1.2.3", "2.2.3"));
}
@Test
public void testIsPatchVersionBump() {
assertTrue(ReleaseNoteGeneration.isPatchVersionBump("1.2.3", "1.2.5"));
assertFalse(ReleaseNoteGeneration.isPatchVersionBump("1.2.3", "1.2.3"));
assertFalse(ReleaseNoteGeneration.isPatchVersionBump("1.2.3", "2.2.3"));
assertFalse(ReleaseNoteGeneration.isPatchVersionBump("1.2.3", "1.3.3"));
}
@Test
public void testPrintClientLibraryVersionDifference() throws Exception {
ReleaseNoteGeneration generation = new ReleaseNoteGeneration();
generation.reportClientLibraryVersionDifference(
ImmutableList.of(
"com.google.cloud:google-cloud-redis", "com.google.cloud:google-cloud-logging"),
ImmutableMap.of(
"com.google.cloud:google-cloud-redis",
"2.8.0",
"com.google.cloud:google-cloud-logging",
"3.12.0"),
ImmutableMap.of(
"com.google.cloud:google-cloud-redis",
"2.9.0",
"com.google.cloud:google-cloud-logging",
"3.13.1"),
"1.1.0");
String report = generation.report.toString();
Truth.assertThat(report)
.contains(
"- google-cloud-redis:2.9.0 (prev:2.8.0; Release Notes: "
+ "[v2.9.0](https://github.com/googleapis/google-cloud-java/releases/tag/v1.1.0))");
Truth.assertThat(report)
.contains(
"- google-cloud-logging:3.13.1 (prev:3.12.0; Release Notes: "
+ "[v3.12.1](https://github.com/googleapis/google-cloud-java/releases/tag/v1.1.0), "
+ "[v3.13.0](https://github.com/googleapis/google-cloud-java/releases/tag/v1.1.0), "
+ "[v3.13.1](https://github.com/googleapis/google-cloud-java/releases/tag/v1.1.0))");
}
@Test
public void testReportClientLibrariesNotableChangeLogs() throws Exception {}
@Test
public void testFetchClientLibraryNotableChangeLog() throws Exception {
String notableChangelog =
ReleaseNoteGeneration.fetchClientLibraryNotableChangeLog(
"java-storage", ImmutableList.of("2.16.0", "2.15.1"));
// A new feature in 2.16.0
Truth.assertThat(notableChangelog)
.contains("- Added a new retention_duration field of Duration type");
// A bug fix in 2.15.1
Truth.assertThat(notableChangelog).contains("- Disable REGAPIC transport in storage v2");
// A dependency update in 2.16.0. A dependency update is not notable.
Truth.assertThat(notableChangelog).doesNotContain("native-maven-plugin");
Truth.assertThat(notableChangelog).doesNotContainMatch("^$");
}
@Test
public void testFilterOnlyRelevantChangelog_splitRepo() throws Exception {
String rawChangelog =
"### Features\n"
+ "\n"
+ "* Add {Compose,Rewrite,StartResumableWrite}Request.object_checksums and"
+ " Bucket.RetentionPolicy.retention_duration"
+ " ([#1790](https://github.com/googleapis/java-storage/issues/1790))"
+ " ([31c1b18](https://github.com/googleapis/java-storage/commit/31c1b18acc3c118e39eb613a82ee292f3e246b8f))\n"
+ "* Added a new retention_duration field of Duration type"
+ " ([31c1b18](https://github.com/googleapis/java-storage/commit/31c1b18acc3c118e39eb613a82ee292f3e246b8f))\n"
+ "* Next release from main branch is 1.122.0\n"
+ "\n"
+ "\n"
+ "### Bug Fixes\n"
+ "\n"
+ "* Removed WriteObject routing annotations"
+ " ([31c1b18](https://github.com/googleapis/java-storage/commit/31c1b18acc3c118e39eb613a82ee292f3e246b8f))\n"
+ "* Disable REGAPIC transport in storage v2\n"
+ "* **deps:** update dependency com.google.apis:google-api-services-dns to"
+ " v1-rev20221110-2.0.0\n"
+ "\n"
+ "\n"
+ "### Documentation";
String notableChangelog = ReleaseNoteGeneration.filterOnlyRelevantChangelog(rawChangelog);
// A new feature in 2.16.0
Truth.assertThat(notableChangelog)
.contains("- Added a new retention_duration field of Duration type");
// A bug fix in 2.15.1
Truth.assertThat(notableChangelog).contains("- Disable REGAPIC transport in storage v2");
// A dependency update in 2.16.0. A dependency update is not notable.
Truth.assertThat(notableChangelog).doesNotContain("native-maven-plugin");
// The forced minor version upgrade is irrelevant to customer
Truth.assertThat(notableChangelog).doesNotContain("1.122.0");
Truth.assertThat(notableChangelog).doesNotContainMatch("^$");
// The list item is replaced with "- "
Truth.assertThat(notableChangelog).doesNotContainMatch("^\\* ");
// Dependency changes, even if it's noted in bug fixes section, shouldn't appear here.
Truth.assertThat(notableChangelog).doesNotContainMatch("deps:");
}
@Test
public void testFetchReleaseNote() throws Exception {
String storageReleaseNote2_16_0 =
ReleaseNoteGeneration.fetchReleaseNote("googleapis", "java-storage", "v2.16.0");
Truth.assertThat(storageReleaseNote2_16_0)
.contains(
"* Add {Compose,Rewrite,StartResumableWrite}Request.object_checksums and"
+ " Bucket.RetentionPolicy.retention_duration"
+ " ([#1790](https://github.com/googleapis/java-storage/issues/1790)) "
+ "([31c1b18](https://github.com/googleapis/java-storage/commit/31c1b18acc3c118e39eb613a82ee292f3e246b8f))");
}
}