Skip to content

Commit

Permalink
Add v2 buf.yaml Configuration/PublishWithWorkspaceTest test cases (#218)
Browse files Browse the repository at this point in the history
  • Loading branch information
drice-buf authored Jul 29, 2024
1 parent c274827 commit 132c14e
Show file tree
Hide file tree
Showing 12 changed files with 148 additions and 1 deletion.
15 changes: 15 additions & 0 deletions src/test/kotlin/build/buf/gradle/ConfigurationTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,23 @@ class ConfigurationTest : AbstractBufIntegrationTest() {
assertFailure()
}

@Test
fun `project can use both buf-yaml and the protobuf-gradle-plugin, protobuf applied first`() {
assertSuccess()
}

@Test
fun `project can use both buf-yaml and the protobuf-gradle-plugin, protobuf applied second`() {
assertSuccess()
}

private fun assertFailure() {
val result = gradleRunner().withArguments(":tasks").buildAndFail()
assertThat(result.output).contains("cannot use both the protobuf-gradle-plugin and a Buf workspace")
}

private fun assertSuccess() {
val result = gradleRunner().withArguments(":tasks").build()
assertThat(result.output).doesNotContain("cannot use both the protobuf-gradle-plugin and a Buf workspace")
}
}
14 changes: 13 additions & 1 deletion src/test/kotlin/build/buf/gradle/PublishWithWorkspaceTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,16 @@

package build.buf.gradle

class PublishWithWorkspaceTest : AbstractPublishTest()
import org.junit.jupiter.api.Test

class PublishWithWorkspaceTest : AbstractPublishTest() {
@Test
fun `publish schema with explicit artifact details v2`() {
super.`publish schema with explicit artifact details`()
}

@Test
fun `publish schema with inferred artifact details v2`() {
super.`publish schema with inferred artifact details`()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
version: v2
modules:
- path: workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
plugins {
id 'java'
id 'com.google.protobuf' version "$protobufGradleVersion"
id 'build.buf'
}

repositories {
mavenCentral()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
version: v2
modules:
- path: workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
plugins {
id 'java'
id 'build.buf'
id 'com.google.protobuf' version "$protobufGradleVersion"
}

repositories {
mavenCentral()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
version: v2
modules:
- path: workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
plugins {
id 'java'
id 'build.buf'
id 'maven-publish'
}

repositories {
mavenCentral()
}

buf {
publishSchema = true
imageArtifact {
groupId = 'foo'
artifactId = 'bar'
version = '2319'
}
}

publishing {
repositories {
maven { url 'build/repos/test' }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright 2023 Buf Technologies, Inc.
//
// Licensed 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.

syntax = "proto3";

package buf.test.v1;

message BasicMessage {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
version: v2
modules:
- path: workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
plugins {
id 'java'
id 'build.buf'
id 'maven-publish'
}

repositories {
mavenCentral()
}

buf {
publishSchema = true
}

publishing {
repositories {
maven { url 'build/repos/test' }
}

publications {
maven(MavenPublication) {
groupId = 'foo'
artifactId = 'bar'
version = '2319'
from components.java
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright 2023 Buf Technologies, Inc.
//
// Licensed 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.

syntax = "proto3";

package buf.test.v1;

message BasicMessage {}

0 comments on commit 132c14e

Please sign in to comment.