Skip to content

Commit

Permalink
chore(cypress): put nextcloud into ram
Browse files Browse the repository at this point in the history
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
  • Loading branch information
skjnldsv committed Aug 21, 2024
1 parent b8dcfb9 commit 4b1287e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
14 changes: 13 additions & 1 deletion cypress/dockerNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,26 @@ export const startNextcloud = async function(branch: string = getCurrentGitBranc
Image: SERVER_IMAGE,
name: CONTAINER_NAME,
HostConfig: {
Binds: [],
Mounts: [{
Target: '/var/www/html/data',
Source: '',
Type: 'tmpfs',
ReadOnly: false,
}],
},
Env: [
`BRANCH=${branch}`,
],
})
await container.start()

// Set proper permissions for the data folder
await runExec(container, ['chown', '-R', 'www-data:www-data', '/var/www/html/data'], false, 'root')
await runExec(container, ['chmod', '0770', '/var/www/html/data'], false, 'root')

// Init Nextcloud
await runExec(container, ['initnc.sh'], true)

// Get container's IP
const ip = await getContainerIP(container)

Expand Down
4 changes: 2 additions & 2 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,12 +290,12 @@ Cypress.Commands.add('runOccCommand', (command: string, options?: Partial<Cypres

Cypress.Commands.add('backupDB', (): Cypress.Chainable<string> => {
const randomString = Math.random().toString(36).substring(7)
cy.exec(`docker exec nextcloud-cypress-tests-server cp /var/www/html/data/owncloud.db /var/www/html/data/owncloud.db-${randomString}`)
cy.exec(`docker exec --user www-data nextcloud-cypress-tests-server cp /var/www/html/data/owncloud.db /var/www/html/data/owncloud.db-${randomString}`)
cy.log(`Created snapshot ${randomString}`)
return cy.wrap(randomString)
})

Cypress.Commands.add('restoreDB', (snapshot: string = 'init') => {
cy.exec(`docker exec nextcloud-cypress-tests-server cp /var/www/html/data/owncloud.db-${snapshot} /var/www/html/data/owncloud.db`)
cy.exec(`docker exec --user www-data nextcloud-cypress-tests-server cp /var/www/html/data/owncloud.db-${snapshot} /var/www/html/data/owncloud.db`)
cy.log(`Restored snapshot ${snapshot}`)
})

0 comments on commit 4b1287e

Please sign in to comment.