Skip to content

Commit

Permalink
genycloud: Omit preliminary login check (#4379)
Browse files Browse the repository at this point in the history
  • Loading branch information
d4vidi authored Feb 22, 2024
1 parent f869a69 commit fd0f359
Show file tree
Hide file tree
Showing 7 changed files with 3 additions and 92 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ class GenyCloudExec {
return this._exec('--version');
}

whoAmI() {
return this._exec('auth whoami');
}

getRecipe(name) {
return this._exec(`recipes list --name "${name}"`);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ describe('Genymotion-cloud executable', () => {

describe.each([
['version', () => uut.getVersion(), `"mock/path/to/gmsaas" --format compactjson --version`],
['whoami', () => uut.whoAmI(), `"mock/path/to/gmsaas" --format compactjson auth whoami`],
['Get Recipe', () => uut.getRecipe(recipeName), `"mock/path/to/gmsaas" --format compactjson recipes list --name "${recipeName}"`],
['Get Instance', () => uut.getInstance(instanceUUID), `"mock/path/to/gmsaas" --format compactjson instances get ${instanceUUID}`],
['Get Instances', () => uut.getInstances(), `"mock/path/to/gmsaas" --format compactjson instances list -q`],
Expand Down

This file was deleted.

This file was deleted.

13 changes: 1 addition & 12 deletions detox/src/devices/validation/android/GenycloudEnvValidator.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,13 @@ class GenycloudEnvValidator extends EnvironmentValidatorBase {
* @param authService { GenyAuthService }
* @param exec { GenyCloudExec }
*/
constructor({ authService, exec }) {
constructor({ exec }) {
super();
this._authService = authService;
this._exec = exec;
}

async validate() {
await this._validateGmsaasVersion();
await this._validateGmsaasAuth();
}

async _validateGmsaasVersion() {
Expand All @@ -32,15 +30,6 @@ class GenycloudEnvValidator extends EnvironmentValidatorBase {
});
}
}

async _validateGmsaasAuth() {
if (!await this._authService.getLoginEmail()) {
throw new DetoxRuntimeError({
message: `Cannot run tests using 'android.genycloud' type devices, because Genymotion was not logged-in to!`,
hint: `Log-in to Genymotion-cloud by running this command (and following instructions):\n${environment.getGmsaasPath()} auth login --help`,
});
}
}
}

module.exports = GenycloudEnvValidator;
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ describe('Genymotion-cloud test environment validator', () => {
const MOCK_GMSAAS_PATH = '/path/to/gmsaas';

let exec;
let authService;
let uut;
beforeEach(() => {
jest.mock('../../../utils/environment');
Expand All @@ -15,20 +14,14 @@ describe('Genymotion-cloud test environment validator', () => {
const GenyExec = jest.genMockFromModule('../../allocation/drivers/android/genycloud/exec/GenyCloudExec');
exec = new GenyExec();

const GenyAuthService = jest.genMockFromModule('../../allocation/drivers/android/genycloud/services/GenyAuthService');
authService = new GenyAuthService();

const GenycloudEnvValidator = require('./GenycloudEnvValidator');
uut = new GenycloudEnvValidator({ authService, exec });
uut = new GenycloudEnvValidator({ exec });
});

const givenProperGmsaasLogin = () => authService.getLoginEmail.mockResolvedValue('[email protected]');
const givenGmsaasLoggedOut = () => authService.getLoginEmail.mockResolvedValue(null);
const givenGmsaasExecVersion = (version) => exec.getVersion.mockResolvedValue({ version });
const givenProperGmsaasExecVersion = () => givenGmsaasExecVersion('1.6.0');

it('should throw an error if gmsaas exec is too old (minor version < 6)', async () => {
givenProperGmsaasLogin();
givenGmsaasExecVersion('1.5.9');

try {
Expand All @@ -43,44 +36,25 @@ describe('Genymotion-cloud test environment validator', () => {
});

it('should accept the gmsaas exec if version is sufficiently new', async () => {
givenProperGmsaasLogin();
givenGmsaasExecVersion('1.6.0');
await uut.validate();
});

it('should accept the gmsaas exec if version is more than sufficiently new', async () => {
givenProperGmsaasLogin();
givenGmsaasExecVersion('1.7.2');
await uut.validate();
});

it('should throw an error if gmsaas exec is too old (major version < 1)', async () => {
givenProperGmsaasLogin();
givenGmsaasExecVersion('0.6.0');

await expect(uut.validate())
.rejects
.toThrowError(`Your Genymotion-Cloud executable (found in ${MOCK_GMSAAS_PATH}) is too old! (version 0.6.0)`);
});

it('should throw an error if not logged-in to gmsaas', async () => {
givenProperGmsaasExecVersion();
givenGmsaasLoggedOut();

try {
await uut.validate();
} catch (e) {
expect(e.constructor.name).toEqual('DetoxRuntimeError');
expect(e.toString()).toContain(`Cannot run tests using 'android.genycloud' type devices, because Genymotion was not logged-in to!`);
expect(e.toString()).toContain(`HINT: Log-in to Genymotion-cloud by running this command (and following instructions):\n${MOCK_GMSAAS_PATH} auth login --help`);
return;
}
throw new Error('Expected an error');
});

it('should not throw an error if properly logged in to gmsaas', async () => {
givenProperGmsaasExecVersion();
givenProperGmsaasLogin();
await uut.validate();
});
});
5 changes: 1 addition & 4 deletions detox/src/devices/validation/factories/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@ class Genycloud extends EnvValidatorFactory {
const serviceLocator = require('../../servicelocator/android');
const exec = serviceLocator.genycloud.exec;

const GenyAuthService = require('../../allocation/drivers/android/genycloud/services/GenyAuthService');
const authService = new GenyAuthService(exec);

const GenycloudEnvValidator = require('../android/GenycloudEnvValidator');
return new GenycloudEnvValidator({ authService, exec });
return new GenycloudEnvValidator({ exec });
}
}

Expand Down

0 comments on commit fd0f359

Please sign in to comment.