Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
kb-kerem committed Apr 17, 2024
1 parent 2c5d867 commit 3299000
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 24 deletions.
37 changes: 19 additions & 18 deletions .github/workflows/java-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,25 @@ jobs:
cache: 'maven'
- name: Build with Maven
run: mvn -B package --file pom.xml

test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push
uses: docker/build-push-action@v5
with:
context: "{{defaultContext}}:visual-java"
tags: saucelabs/java-sdk
file: Dockerfile
load: true
- run: |
npm ci
npx jest
working-directory: tests
env:
SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }}
SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }}
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push
uses: docker/build-push-action@v5
with:
context: '{{defaultContext}}:visual-java'
tags: saucelabs/visual-java
file: Dockerfile
load: true
- run: |
npm ci
npm run test
working-directory: tests
env:
SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }}
SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }}
CONTAINER_IMAGE_NAME: saucelabs/visual-java
8 changes: 4 additions & 4 deletions tests/env-vars.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ let fileOutput: FileHandle | undefined;
let dockerOutput = '';
let buildId = '';

describe('Java', () => {
describe('Env var tests', () => {
it(
'runs the docker image with env vars in place',
async () => {
Expand All @@ -33,7 +33,7 @@ describe('Java', () => {
-e SAUCE_VISUAL_BRANCH \\
-e SAUCE_VISUAL_DEFAULT_BRANCH \\
-e SAUCE_VISUAL_BUILD_NAME \\
saucelabs/java-sdk`,
${process.env.CONTAINER_IMAGE_NAME}`,
{
displayOutputOnFailure: true,
pipeOutput: false,
Expand All @@ -53,7 +53,7 @@ describe('Java', () => {
2 * 60 * 1000
);

it('returns link to builds', async () => {
it('returns a valid build link', async () => {
expect(dockerOutput.length).toBeGreaterThan(0);

const links = [...dockerOutput.matchAll(RE_VISUAL_BUILD_LINK)];
Expand All @@ -62,7 +62,7 @@ describe('Java', () => {
});

it(
'generates a valid build',
'env vars are processed correctly',
async () => {
expect(buildId).toMatch(RE_VISUAL_BUILD_ID);

Expand Down
4 changes: 2 additions & 2 deletions tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
"typescript": "^5.2.2"
},
"scripts": {
"test": "jest --runInBand"
"test-env-vars": "jest --runInBand env-vars.spec.ts --container-image=saucelabs/visual-java"
},
"dependencies": {
"@saucelabs/visual": "^0.3.352"
}
}
}

0 comments on commit 3299000

Please sign in to comment.