@ -40,7 +40,7 @@ func TestRelease_Create(t *testing.T) {
IsDraft : false ,
IsDraft : false ,
IsPrerelease : false ,
IsPrerelease : false ,
IsTag : false ,
IsTag : false ,
} , nil ) )
} , nil , "" ) )
assert . NoError ( t , CreateRelease ( gitRepo , & models . Release {
assert . NoError ( t , CreateRelease ( gitRepo , & models . Release {
RepoID : repo . ID ,
RepoID : repo . ID ,
@ -52,7 +52,7 @@ func TestRelease_Create(t *testing.T) {
IsDraft : false ,
IsDraft : false ,
IsPrerelease : false ,
IsPrerelease : false ,
IsTag : false ,
IsTag : false ,
} , nil ) )
} , nil , "" ) )
assert . NoError ( t , CreateRelease ( gitRepo , & models . Release {
assert . NoError ( t , CreateRelease ( gitRepo , & models . Release {
RepoID : repo . ID ,
RepoID : repo . ID ,
@ -64,7 +64,7 @@ func TestRelease_Create(t *testing.T) {
IsDraft : false ,
IsDraft : false ,
IsPrerelease : false ,
IsPrerelease : false ,
IsTag : false ,
IsTag : false ,
} , nil ) )
} , nil , "" ) )
assert . NoError ( t , CreateRelease ( gitRepo , & models . Release {
assert . NoError ( t , CreateRelease ( gitRepo , & models . Release {
RepoID : repo . ID ,
RepoID : repo . ID ,
@ -76,7 +76,7 @@ func TestRelease_Create(t *testing.T) {
IsDraft : true ,
IsDraft : true ,
IsPrerelease : false ,
IsPrerelease : false ,
IsTag : false ,
IsTag : false ,
} , nil ) )
} , nil , "" ) )
assert . NoError ( t , CreateRelease ( gitRepo , & models . Release {
assert . NoError ( t , CreateRelease ( gitRepo , & models . Release {
RepoID : repo . ID ,
RepoID : repo . ID ,
@ -88,7 +88,7 @@ func TestRelease_Create(t *testing.T) {
IsDraft : false ,
IsDraft : false ,
IsPrerelease : true ,
IsPrerelease : true ,
IsTag : false ,
IsTag : false ,
} , nil ) )
} , nil , "" ) )
assert . NoError ( t , CreateRelease ( gitRepo , & models . Release {
assert . NoError ( t , CreateRelease ( gitRepo , & models . Release {
RepoID : repo . ID ,
RepoID : repo . ID ,
@ -100,7 +100,7 @@ func TestRelease_Create(t *testing.T) {
IsDraft : false ,
IsDraft : false ,
IsPrerelease : false ,
IsPrerelease : false ,
IsTag : true ,
IsTag : true ,
} , nil ) )
} , nil , "test" ) )
}
}
func TestRelease_Update ( t * testing . T ) {
func TestRelease_Update ( t * testing . T ) {
@ -125,7 +125,7 @@ func TestRelease_Update(t *testing.T) {
IsDraft : false ,
IsDraft : false ,
IsPrerelease : false ,
IsPrerelease : false ,
IsTag : false ,
IsTag : false ,
} , nil ) )
} , nil , "" ) )
release , err := models . GetRelease ( repo . ID , "v1.1.1" )
release , err := models . GetRelease ( repo . ID , "v1.1.1" )
assert . NoError ( t , err )
assert . NoError ( t , err )
releaseCreatedUnix := release . CreatedUnix
releaseCreatedUnix := release . CreatedUnix
@ -147,7 +147,7 @@ func TestRelease_Update(t *testing.T) {
IsDraft : true ,
IsDraft : true ,
IsPrerelease : false ,
IsPrerelease : false ,
IsTag : false ,
IsTag : false ,
} , nil ) )
} , nil , "" ) )
release , err = models . GetRelease ( repo . ID , "v1.2.1" )
release , err = models . GetRelease ( repo . ID , "v1.2.1" )
assert . NoError ( t , err )
assert . NoError ( t , err )
releaseCreatedUnix = release . CreatedUnix
releaseCreatedUnix = release . CreatedUnix
@ -169,7 +169,7 @@ func TestRelease_Update(t *testing.T) {
IsDraft : false ,
IsDraft : false ,
IsPrerelease : true ,
IsPrerelease : true ,
IsTag : false ,
IsTag : false ,
} , nil ) )
} , nil , "" ) )
release , err = models . GetRelease ( repo . ID , "v1.3.1" )
release , err = models . GetRelease ( repo . ID , "v1.3.1" )
assert . NoError ( t , err )
assert . NoError ( t , err )
releaseCreatedUnix = release . CreatedUnix
releaseCreatedUnix = release . CreatedUnix
@ -205,12 +205,12 @@ func TestRelease_createTag(t *testing.T) {
IsPrerelease : false ,
IsPrerelease : false ,
IsTag : false ,
IsTag : false ,
}
}
assert . NoError ( t , createTag ( gitRepo , release ) )
assert . NoError ( t , createTag ( gitRepo , release , "" ) )
assert . NotEmpty ( t , release . CreatedUnix )
assert . NotEmpty ( t , release . CreatedUnix )
releaseCreatedUnix := release . CreatedUnix
releaseCreatedUnix := release . CreatedUnix
time . Sleep ( 2 * time . Second ) // sleep 2 seconds to ensure a different timestamp
time . Sleep ( 2 * time . Second ) // sleep 2 seconds to ensure a different timestamp
release . Note = "Changed note"
release . Note = "Changed note"
assert . NoError ( t , createTag ( gitRepo , release ) )
assert . NoError ( t , createTag ( gitRepo , release , "" ) )
assert . Equal ( t , int64 ( releaseCreatedUnix ) , int64 ( release . CreatedUnix ) )
assert . Equal ( t , int64 ( releaseCreatedUnix ) , int64 ( release . CreatedUnix ) )
// Test a changed draft
// Test a changed draft
@ -225,11 +225,11 @@ func TestRelease_createTag(t *testing.T) {
IsPrerelease : false ,
IsPrerelease : false ,
IsTag : false ,
IsTag : false ,
}
}
assert . NoError ( t , createTag ( gitRepo , release ) )
assert . NoError ( t , createTag ( gitRepo , release , "" ) )
releaseCreatedUnix = release . CreatedUnix
releaseCreatedUnix = release . CreatedUnix
time . Sleep ( 2 * time . Second ) // sleep 2 seconds to ensure a different timestamp
time . Sleep ( 2 * time . Second ) // sleep 2 seconds to ensure a different timestamp
release . Title = "Changed title"
release . Title = "Changed title"
assert . NoError ( t , createTag ( gitRepo , release ) )
assert . NoError ( t , createTag ( gitRepo , release , "" ) )
assert . Less ( t , int64 ( releaseCreatedUnix ) , int64 ( release . CreatedUnix ) )
assert . Less ( t , int64 ( releaseCreatedUnix ) , int64 ( release . CreatedUnix ) )
// Test a changed pre-release
// Test a changed pre-release
@ -244,11 +244,20 @@ func TestRelease_createTag(t *testing.T) {
IsPrerelease : true ,
IsPrerelease : true ,
IsTag : false ,
IsTag : false ,
}
}
assert . NoError ( t , createTag ( gitRepo , release ) )
assert . NoError ( t , createTag ( gitRepo , release , "" ) )
releaseCreatedUnix = release . CreatedUnix
releaseCreatedUnix = release . CreatedUnix
time . Sleep ( 2 * time . Second ) // sleep 2 seconds to ensure a different timestamp
time . Sleep ( 2 * time . Second ) // sleep 2 seconds to ensure a different timestamp
release . Title = "Changed title"
release . Title = "Changed title"
release . Note = "Changed note"
release . Note = "Changed note"
assert . NoError ( t , createTag ( gitRepo , release ) )
assert . NoError ( t , createTag ( gitRepo , release , "" ) )
assert . Equal ( t , int64 ( releaseCreatedUnix ) , int64 ( release . CreatedUnix ) )
assert . Equal ( t , int64 ( releaseCreatedUnix ) , int64 ( release . CreatedUnix ) )
}
}
func TestCreateNewTag ( t * testing . T ) {
assert . NoError ( t , models . PrepareTestDatabase ( ) )
user := models . AssertExistsAndLoadBean ( t , & models . User { ID : 2 } ) . ( * models . User )
repo := models . AssertExistsAndLoadBean ( t , & models . Repository { ID : 1 } ) . ( * models . Repository )
assert . NoError ( t , CreateNewTag ( user , repo , "master" , "v2.0" ,
"v2.0 is released \n\n BUGFIX: .... \n\n 123" ) )
}