refactor(branch): rename default branch to main
This commit is contained in:
@@ -23,8 +23,8 @@ module.exports = {
|
||||
let [ streamId ] = await Streams( ).returning( 'id' ).insert( stream )
|
||||
await Acl( ).insert( { userId: ownerId, resourceId: streamId, role: 'stream:owner' } )
|
||||
|
||||
// Create a default master branch
|
||||
await createBranch( { name: 'master', description: 'default branch', streamId: streamId, authorId: ownerId } )
|
||||
// Create a default main branch
|
||||
await createBranch( { name: 'main', description: 'default branch', streamId: streamId, authorId: ownerId } )
|
||||
return streamId
|
||||
},
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ describe( 'Branches', ( ) => {
|
||||
|
||||
it( 'Should not allow duplicate branch names', async ( ) => {
|
||||
try {
|
||||
await createBranch( { name: 'master', streamId: stream.id, authorId: user.id } )
|
||||
await createBranch( { name: 'main', streamId: stream.id, authorId: user.id } )
|
||||
assert.fail( 'Duplicate branches should not be allowed.' )
|
||||
} catch ( err ) {
|
||||
expect( err.message ).to.contain( 'duplicate key value violates unique constraint' )
|
||||
@@ -83,8 +83,8 @@ describe( 'Branches', ( ) => {
|
||||
|
||||
it( 'Should get all stream branches', async ( ) => {
|
||||
|
||||
await createBranch( { name: 'master-faster', streamId: stream.id, authorId: user.id } )
|
||||
await createBranch( { name: 'master-blaster', streamId: stream.id, authorId: user.id } )
|
||||
await createBranch( { name: 'main-faster', streamId: stream.id, authorId: user.id } )
|
||||
await createBranch( { name: 'main-blaster', streamId: stream.id, authorId: user.id } )
|
||||
await createBranch( { name: 'blaster-farter', streamId: stream.id, authorId: user.id } )
|
||||
|
||||
let { items, cursor, totalCount } = await getBranchesByStreamId( { streamId: stream.id } )
|
||||
|
||||
@@ -76,15 +76,15 @@ describe( 'Commits', ( ) => {
|
||||
let commitId1, commitId2, commitId3
|
||||
|
||||
it( 'Should create a commit by branch name', async ( ) => {
|
||||
commitId1 = await createCommitByBranchName( { streamId: stream.id, branchName: 'master', message: 'first commit', objectId: testObject.id, authorId: user.id } )
|
||||
commitId1 = await createCommitByBranchName( { streamId: stream.id, branchName: 'main', message: 'first commit', objectId: testObject.id, authorId: user.id } )
|
||||
expect( commitId1 ).to.be.a.string
|
||||
} )
|
||||
|
||||
it( 'Should create a commit with a previous commit id', async ( ) => {
|
||||
commitId2 = await createCommitByBranchName( { streamId: stream.id, branchName: 'master', message: 'second commit', objectId: testObject2.id, authorId: user.id, previousCommitIds: [ commitId1 ] } )
|
||||
commitId2 = await createCommitByBranchName( { streamId: stream.id, branchName: 'main', message: 'second commit', objectId: testObject2.id, authorId: user.id, previousCommitIds: [ commitId1 ] } )
|
||||
expect( commitId2 ).to.be.a.string
|
||||
|
||||
commitId3 = await createCommitByBranchName( { streamId: stream.id, branchName: 'master', message: 'third commit', objectId: testObject3.id, authorId: user.id, previousCommitIds: [ commitId1, commitId2 ] } )
|
||||
commitId3 = await createCommitByBranchName( { streamId: stream.id, branchName: 'main', message: 'third commit', objectId: testObject3.id, authorId: user.id, previousCommitIds: [ commitId1, commitId2 ] } )
|
||||
|
||||
expect( commitId3 ).to.be.a.string
|
||||
} )
|
||||
@@ -95,7 +95,7 @@ describe( 'Commits', ( ) => {
|
||||
} )
|
||||
|
||||
it( 'Should delete a commit', async ( ) => {
|
||||
let tempCommit = await createCommitByBranchName( { streamId: stream.id, branchName: 'master', message: 'temp commit', objectId: testObject.id, authorId: user.id } )
|
||||
let tempCommit = await createCommitByBranchName( { streamId: stream.id, branchName: 'main', message: 'temp commit', objectId: testObject.id, authorId: user.id } )
|
||||
|
||||
let res = await deleteCommit( { id: tempCommit } )
|
||||
expect( res ).to.equal( 1 )
|
||||
@@ -111,19 +111,19 @@ describe( 'Commits', ( ) => {
|
||||
for ( let i = 0; i < 10; i++ ) {
|
||||
let t = { qux: i }
|
||||
t.id = await createObject( t )
|
||||
await createCommitByBranchName( { streamId: stream.id, branchName: 'master', message: `commit # ${i+3}`, objectId: t.id, authorId: user.id } )
|
||||
await createCommitByBranchName( { streamId: stream.id, branchName: 'main', message: `commit # ${i+3}`, objectId: t.id, authorId: user.id } )
|
||||
}
|
||||
|
||||
let { commits, cursor } = await getCommitsByBranchName( { streamId: stream.id, branchName: 'master', limit: 2 } )
|
||||
let { commits, cursor } = await getCommitsByBranchName( { streamId: stream.id, branchName: 'main', limit: 2 } )
|
||||
expect( commits ).to.be.an( 'array' )
|
||||
expect( commits.length ).to.equal( 2 )
|
||||
|
||||
let { commits: commits2, cursor: cursor2 } = await getCommitsByBranchName( { streamId: stream.id, branchName: 'master', limit: 5, cursor: cursor } )
|
||||
let { commits: commits2, cursor: cursor2 } = await getCommitsByBranchName( { streamId: stream.id, branchName: 'main', limit: 5, cursor: cursor } )
|
||||
expect( commits2.length ).to.equal( 5 )
|
||||
} )
|
||||
|
||||
it( 'Should get the commit count from a branch', async ( ) => {
|
||||
let c = await getCommitsTotalCountByBranchName( { streamId: stream.id, branchName: 'master' } )
|
||||
let c = await getCommitsTotalCountByBranchName( { streamId: stream.id, branchName: 'main' } )
|
||||
expect( c ).to.equal( 13 )
|
||||
} )
|
||||
|
||||
@@ -158,7 +158,7 @@ describe( 'Commits', ( ) => {
|
||||
|
||||
it( 'Should get the public commits of an user only', async ( ) => {
|
||||
let privateStreamId = await createStream( { name: 'private', isPublic: false, ownerId: user.id } )
|
||||
let commitId = await createCommitByBranchName( { streamId: privateStreamId, branchName: 'master', message: 'first commit', objectId: testObject.id, authorId: user.id } )
|
||||
let commitId = await createCommitByBranchName( { streamId: privateStreamId, branchName: 'main', message: 'first commit', objectId: testObject.id, authorId: user.id } )
|
||||
|
||||
let { commits, cursor } = await getCommitsByUserId( { userId: user.id, limit: 1000 } )
|
||||
expect( commits.length ).to.equal( 23 )
|
||||
|
||||
@@ -264,7 +264,7 @@ describe( 'GraphQL API Core @core-api', ( ) => {
|
||||
c1.message = 'what a message for a first commit'
|
||||
c1.streamId = ts1
|
||||
c1.objectId = objIds[ 0 ]
|
||||
c1.branchName = 'master'
|
||||
c1.branchName = 'main'
|
||||
|
||||
let res = await sendRequest( userA.token, { query: `mutation( $myCommit: CommitCreateInput! ) { commitCreate( commit: $myCommit ) }`, variables: { myCommit: c1 } } )
|
||||
|
||||
@@ -277,7 +277,7 @@ describe( 'GraphQL API Core @core-api', ( ) => {
|
||||
c2.message = 'what a message for a second commit'
|
||||
c2.streamId = ts1
|
||||
c2.objectId = objIds[ 1 ]
|
||||
c2.branchName = 'master'
|
||||
c2.branchName = 'main'
|
||||
c2.previousCommitIds = [ c1.id ]
|
||||
|
||||
res = await sendRequest( userA.token, { query: `mutation( $myCommit: CommitCreateInput! ) { commitCreate( commit: $myCommit ) }`, variables: { myCommit: c2 } } )
|
||||
@@ -388,7 +388,7 @@ describe( 'GraphQL API Core @core-api', ( ) => {
|
||||
await sendRequest( userA.token, { query: `mutation{ streamRevokePermission( permissionParams: {streamId: "${ts1}", userId: "${userC.id}"} ) }` } )
|
||||
} )
|
||||
|
||||
it( 'Should commit to a non-master branch as well...', async ( ) => {
|
||||
it( 'Should commit to a non-main branch as well...', async ( ) => {
|
||||
let cc = {}
|
||||
cc.message = 'what a message for a second commit'
|
||||
cc.streamId = ts1
|
||||
@@ -459,7 +459,7 @@ describe( 'GraphQL API Core @core-api', ( ) => {
|
||||
message: `what a message for commit number ${i}`,
|
||||
streamId: ts1,
|
||||
objectId: objIds[ i ],
|
||||
branchName: 'master',
|
||||
branchName: 'main',
|
||||
}
|
||||
let res = await sendRequest( userA.token, { query: `mutation( $myCommit: CommitCreateInput! ) { commitCreate( commit: $myCommit ) }`, variables: { myCommit: c1 } } )
|
||||
}
|
||||
@@ -692,7 +692,7 @@ describe( 'GraphQL API Core @core-api', ( ) => {
|
||||
let query = `
|
||||
query {
|
||||
stream( id: "${ts1}" ) {
|
||||
branch( name: "master" ) {
|
||||
branch( name: "main" ) {
|
||||
id
|
||||
name
|
||||
commits( limit: 5 ) {
|
||||
@@ -719,7 +719,7 @@ describe( 'GraphQL API Core @core-api', ( ) => {
|
||||
let query2 = `
|
||||
query {
|
||||
stream( id: "${ts1}" ) {
|
||||
branch( name: "master" ) {
|
||||
branch( name: "main" ) {
|
||||
id
|
||||
name
|
||||
commits( limit: 3, cursor: "${res.body.data.stream.branch.commits.cursor}" ) {
|
||||
|
||||
@@ -463,12 +463,12 @@ describe( 'GraphQL API Subscriptions @gql-subscriptions', ( ) => {
|
||||
await sleep( 500 )
|
||||
|
||||
let cc1 = await sendRequest( userA.token, {
|
||||
query: `mutation { commitCreate ( commit: { streamId: "${streamId}", branchName: "master", objectId: "${objId1}" } ) }`
|
||||
query: `mutation { commitCreate ( commit: { streamId: "${streamId}", branchName: "main", objectId: "${objId1}" } ) }`
|
||||
} )
|
||||
.expect( 200 )
|
||||
.expect( noErrors )
|
||||
let cc2 = await sendRequest( userA.token, {
|
||||
query: `mutation { commitCreate ( commit: { streamId: "${streamId}", branchName: "master", objectId: "${objId2}" } ) }`
|
||||
query: `mutation { commitCreate ( commit: { streamId: "${streamId}", branchName: "main", objectId: "${objId2}" } ) }`
|
||||
} )
|
||||
.expect( 200 )
|
||||
.expect( noErrors )
|
||||
@@ -483,7 +483,7 @@ describe( 'GraphQL API Subscriptions @gql-subscriptions', ( ) => {
|
||||
const streamId = resSC.body.data.streamCreate
|
||||
const resOC = await sendRequest( userA.token, { query: `mutation { objectCreate( objectInput: {streamId: "${streamId}", objects: {hello: "goodbye 🌊"}} ) }` } )
|
||||
const objId = resOC.body.data.objectCreate
|
||||
const resCC = await sendRequest( userA.token, { query: `mutation { commitCreate ( commit: { streamId: "${streamId}", branchName: "master", objectId: "${objId}" } ) }` } )
|
||||
const resCC = await sendRequest( userA.token, { query: `mutation { commitCreate ( commit: { streamId: "${streamId}", branchName: "main", objectId: "${objId}" } ) }` } )
|
||||
const commitId = resCC.body.data.commitCreate
|
||||
|
||||
let eventNum = 0
|
||||
@@ -517,7 +517,7 @@ describe( 'GraphQL API Subscriptions @gql-subscriptions', ( ) => {
|
||||
const streamId = resSC.body.data.streamCreate
|
||||
const resOC = await sendRequest( userA.token, { query: `mutation { objectCreate( objectInput: {streamId: "${streamId}", objects: {hello: "goodbye 🌊"}} ) }` } )
|
||||
const objId = resOC.body.data.objectCreate
|
||||
const resCC = await sendRequest( userA.token, { query: `mutation { commitCreate ( commit: { streamId: "${streamId}", branchName: "master", objectId: "${objId}" } ) }` } )
|
||||
const resCC = await sendRequest( userA.token, { query: `mutation { commitCreate ( commit: { streamId: "${streamId}", branchName: "main", objectId: "${objId}" } ) }` } )
|
||||
const commitId = resCC.body.data.commitCreate
|
||||
|
||||
let eventNum = 0
|
||||
@@ -558,7 +558,7 @@ describe( 'GraphQL API Subscriptions @gql-subscriptions', ( ) => {
|
||||
await sleep( 500 )
|
||||
|
||||
let cc = await sendRequest( userA.token, {
|
||||
query: `mutation { commitCreate ( commit: { streamId: "${streamId}", branchName: "master", objectId: "${objId}" } ) }`
|
||||
query: `mutation { commitCreate ( commit: { streamId: "${streamId}", branchName: "main", objectId: "${objId}" } ) }`
|
||||
} )
|
||||
.expect( 200 )
|
||||
.expect( noErrors )
|
||||
|
||||
Reference in New Issue
Block a user