Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fix sonar execution #18

Merged
merged 5 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
environment: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository && 'external' || 'internal' }}
runs-on: ubuntu-latest
steps:
- run: true
- run: "true"

build-test:
needs: authorize
Expand All @@ -23,3 +23,7 @@ jobs:
with:
java: "[ 17, 21 ]"

dependabot:
needs: build-test
uses: liquibase/build-logic/.github/workflows/[email protected]
secrets: inherit
8 changes: 8 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
<sonar.scm.provider>git</sonar.scm.provider>
<sonar.qualitygate.wait>true</sonar.qualitygate.wait>
<sonar.sources>src/main/java</sonar.sources>
<sonar.tests>src/test/groovy</sonar.tests>
</properties>

<dependencies>
Expand All @@ -57,6 +59,12 @@
<artifactId>liquibase-core</artifactId>
<version>4.27.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.13</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.example.change;

import liquibase.statement.core.CreateTableStatement;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;

class PrefixedCreateTableChangeTest {

Check notice

Code scanning / CodeQL

Unused classes and interfaces Note test

Unused class: PrefixedCreateTableChangeTest is not referenced within this codebase. If not used as an external API it should be removed.

private PrefixedCreateTableChange prefixedCreateTableChange;

@BeforeEach
void setUp() {
prefixedCreateTableChange = new PrefixedCreateTableChange();
}

@Test
void getPrefix_returnsNull_whenNotSet() {
assertNull(prefixedCreateTableChange.getPrefix());
}

@Test
void getPrefix_returnsPrefix_whenSet() {
String expectedPrefix = "testPrefix";
prefixedCreateTableChange.setPrefix(expectedPrefix);

assertEquals(expectedPrefix, prefixedCreateTableChange.getPrefix());
}

@Test
void generateCreateTableStatement_usesStandardPrefix_whenPrefixNotSet() {
prefixedCreateTableChange.setTableName("testTable");

CreateTableStatement statement = prefixedCreateTableChange.generateCreateTableStatement();

assertTrue(statement.getTableName().startsWith("standard_"));
}

@Test
void generateCreateTableStatement_usesSetPrefix_whenPrefixSet() {
String expectedPrefix = "testPrefix";
prefixedCreateTableChange.setPrefix(expectedPrefix);
prefixedCreateTableChange.setTableName("testTable");

CreateTableStatement statement = prefixedCreateTableChange.generateCreateTableStatement();

assertTrue(statement.getTableName().startsWith(expectedPrefix + "_"));
}
}
Loading