Skip to content

Commit

Permalink
Merge pull request #17648 from mshima/skip_ci-tests
Browse files Browse the repository at this point in the history
Bump mocha-expect-snapshot and improve some tests.
  • Loading branch information
DanielFran authored Jan 22, 2022
2 parents ab4a005 + e54ecf2 commit e478e38
Show file tree
Hide file tree
Showing 7 changed files with 174 additions and 181 deletions.
1 change: 1 addition & 0 deletions generators/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ module.exports = {
copyWebResource,
renderContent,
deepFind,
escapeRegExp,
getJavadoc,
buildEnumInfo,
getEnumInfo,
Expand Down
22 changes: 12 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
"fs-extra": "10.0.0",
"jsdoc": "3.6.7",
"mocha": "9.1.4",
"mocha-expect-snapshot": "1.1.1",
"mocha-expect-snapshot": "2.1.0",
"proxyquire": "2.1.3",
"sinon": "12.0.1",
"sinon-chai": "3.7.0",
Expand Down
119 changes: 119 additions & 0 deletions test/__snapshots__/docker-compose.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1248,6 +1248,125 @@ scrape_configs:
}
`;
exports[`JHipster Docker Compose Sub Generator gateway and one microservice, without monitoring should match files snapshot 1`] = `
Object {
".yo-rc.json": Object {
"contents": "{
\\"generator-jhipster\\": {
\\"appsFolders\\": [\\"01-gateway\\", \\"02-mysql\\"],
\\"clusteredDbApps\\": {},
\\"directoryPath\\": \\"./\\",
\\"gatewayType\\": \\"SpringCloudGateway\\",
\\"jwtSecretKey\\": \\"SECRET--50\\",
\\"monitoring\\": \\"no\\",
\\"serviceDiscoveryType\\": \\"eureka\\"
}
}
",
"stateCleared": "modified",
},
"README-DOCKER-COMPOSE.md": Object {
"contents": "# JHipster generated Docker-Compose configuration
## Usage
Launch all your infrastructure by running: \`docker-compose up -d\`.
## Configured Docker services
### Service registry and configuration server:
- [JHipster Registry](http://localhost:8761)
### Applications and dependencies:
- jhgate (gateway application)
- jhgate's mysql database
- jhgate's no search engine
- msmysql (microservice application)
- msmysql's mysql database
- msmysql's no search engine
### Additional Services:
",
"stateCleared": "modified",
},
"central-server-config/application.yml": Object {
"contents": "#common configuration shared between all applications
configserver:
name: Docker JHipster Registry
status: Connected to the JHipster Registry running in Docker
jhipster:
security:
authentication:
jwt:
base64-secret: SECRET--50
eureka:
client:
service-url:
defaultZone: http://admin:\${jhipster.registry.password}@jhipster-registry:8761/eureka/
",
"stateCleared": "modified",
},
"docker-compose.yml": Object {
"contents": "services:
jhgate:
image: jhgate
environment:
- SPRING_PROFILES_ACTIVE=prod
- SPRING_CLOUD_CONFIG_URI=http://admin:admin@jhipster-registry:8761/config
- SPRING_DATASOURCE_URL=jdbc:mysql://jhgate-mysql:3306/jhgate?useUnicode=true&characterEncoding=utf8&useSSL=false&createDatabaseIfNotExist=true
- JHIPSTER_REGISTRY_PASSWORD=admin
ports:
- \\"8080:8080\\"
jhgate-mysql:
image: mysql:8.0.27
environment:
- MYSQL_ALLOW_EMPTY_PASSWORD=yes
- MYSQL_DATABASE=jhgate
command: mysqld --lower_case_table_names=1 --skip-ssl --character_set_server=utf8mb4 --explicit_defaults_for_timestamp
msmysql:
image: msmysql
environment:
- SPRING_PROFILES_ACTIVE=prod
- SPRING_CLOUD_CONFIG_URI=http://admin:admin@jhipster-registry:8761/config
- SPRING_DATASOURCE_URL=jdbc:mysql://msmysql-mysql:3306/msmysql?useUnicode=true&characterEncoding=utf8&useSSL=false&createDatabaseIfNotExist=true
- JHIPSTER_REGISTRY_PASSWORD=admin
msmysql-mysql:
image: mysql:8.0.27
environment:
- MYSQL_ALLOW_EMPTY_PASSWORD=yes
- MYSQL_DATABASE=msmysql
command: mysqld --lower_case_table_names=1 --skip-ssl --character_set_server=utf8mb4 --explicit_defaults_for_timestamp
jhipster-registry:
image: jhipster/jhipster-registry:v7.1.0
volumes:
- ./central-server-config:/central-config
# By default the JHipster Registry runs with the \\"dev\\" and \\"native\\"
# Spring profiles.
# \\"native\\" profile means the filesystem is used to store data, see
# http://cloud.spring.io/spring-cloud-config/spring-cloud-config.html
environment:
- _JAVA_OPTIONS=-Xmx512m -Xms256m
- SPRING_PROFILES_ACTIVE=dev
- SPRING_SECURITY_USER_PASSWORD=admin
- JHIPSTER_REGISTRY_PASSWORD=admin
- SPRING_CLOUD_CONFIG_SERVER_COMPOSITE_0_TYPE=native
- SPRING_CLOUD_CONFIG_SERVER_COMPOSITE_0_SEARCH_LOCATIONS=file:./central-config
# - SPRING_CLOUD_CONFIG_SERVER_COMPOSITE_0_TYPE=git
# - SPRING_CLOUD_CONFIG_SERVER_COMPOSITE_0_URI=https://github.com/jhipster/jhipster-registry/
# - SPRING_CLOUD_CONFIG_SERVER_COMPOSITE_0_SEARCH_PATHS=central-config
ports:
- 8761:8761
",
"stateCleared": "modified",
},
}
`;
exports[`JHipster Docker Compose Sub Generator monolith should match files snapshot 1`] = `
Object {
".yo-rc.json": Object {
Expand Down
39 changes: 1 addition & 38 deletions test/docker-compose.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ describe('JHipster Docker Compose Sub Generator', () => {
});
});

describe('gateway and one microservice', () => {
describe('gateway and one microservice, without monitoring', () => {
let runResult;
before(async () => {
runResult = await helpers
Expand Down Expand Up @@ -222,43 +222,6 @@ describe('JHipster Docker Compose Sub Generator', () => {
});
});

describe('gateway and one microservice', () => {
let runResult;
before(async () => {
runResult = await helpers
.create(require.resolve('../generators/docker-compose'))
.doInDir(dir => {
fse.copySync(path.join(__dirname, './templates/compose/01-gateway'), path.join(dir, './01-gateway'));
fse.copySync(path.join(__dirname, './templates/compose/02-mysql'), path.join(dir, './02-mysql'));
})
.withOptions({ skipChecks: true, reproducibleTests: true })
.withPrompts({
deploymentApplicationType: MICROSERVICE,
directoryPath: './',
chosenApps: ['01-gateway', '02-mysql'],
clusteredDbApps: [],
})
.run();
});
it('should match files snapshot', function () {
expect(runResult.getSnapshot()).toMatchSnapshot();
});
it('creates expected default files', () => {
assert.file(expectedFiles.dockercompose);
});
it('creates jhipster-registry content', () => {
assert.fileContent('docker-compose.yml', /jhipster-registry:8761\/config/);
});
it('no prometheus files', () => {
assert.noFile(expectedFiles.prometheus);
});
it('creates compose file without container_name, external_links, links', () => {
assert.noFileContent('docker-compose.yml', /container_name:/);
assert.noFileContent('docker-compose.yml', /external_links:/);
assert.noFileContent('docker-compose.yml', /links:/);
});
});

describe('gateway and one microservice, with prometheus', () => {
let runResult;
before(async () => {
Expand Down
67 changes: 0 additions & 67 deletions test/openshift.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,43 +97,6 @@ describe('JHipster OpenShift Sub Generator', () => {
});
});

describe('gateway and one microservice with mysql', () => {
let runResult;
before(async () => {
runResult = await helpers
.create(require.resolve('../generators/openshift'))
.inTmpDir(dir => {
fse.copySync(path.join(__dirname, './templates/compose/01-gateway'), path.join(dir, './01-gateway'));
fse.copySync(path.join(__dirname, './templates/compose/02-mysql'), path.join(dir, './02-mysql'));
})
.withOptions({ skipChecks: true, reproducibleTests: true })
.withPrompts({
deploymentApplicationType: 'microservice',
directoryPath: './',
chosenApps: ['01-gateway', '02-mysql'],
dockerRepositoryName: 'ocrepo',
dockerPushCommand: 'docker push',
openshiftNamespace: 'default',
})
.run();
});
it('should match files snapshot', function () {
expect(runResult.getSnapshot()).toMatchSnapshot();
});
it('creates expected registry files', () => {
assert.file(expectedFiles.eurekaregistry);
});
it('creates expected scc files', () => {
assert.file(expectedFiles.sccconfig);
});
it('creates expected gateway files', () => {
assert.file(expectedFiles.applcgw);
});
it('creates expected msmysql files', () => {
assert.file(expectedFiles.msmysql);
});
});

describe('two microservices backed by mysql and postgres without gateway', () => {
let runResult;
before(async () => {
Expand Down Expand Up @@ -257,34 +220,4 @@ describe('JHipster OpenShift Sub Generator', () => {
assert.file(expectedFiles.sccconfig);
});
});

describe('monolith application', () => {
let runResult;
before(async () => {
runResult = await helpers
.create(require.resolve('../generators/openshift'))
.inTmpDir(dir => {
fse.copySync(path.join(__dirname, './templates/compose/08-monolith'), path.join(dir, './08-monolith'));
})
.withOptions({ skipChecks: true, reproducibleTests: true })
.withPrompts({
deploymentApplicationType: 'monolith',
directoryPath: './',
chosenApps: ['08-monolith'],
dockerRepositoryName: 'ocrepo',
dockerPushCommand: 'docker push',
openshiftNamespace: 'default',
})
.run();
});
it('should match files snapshot', function () {
expect(runResult.getSnapshot()).toMatchSnapshot();
});
it('creates expected default files', () => {
assert.file(expectedFiles.monolith);
});
it('creates expected scc files', () => {
assert.file(expectedFiles.sccconfig);
});
});
});
Loading

0 comments on commit e478e38

Please sign in to comment.