@@ -69,17 +69,47 @@ func TestNewReleasePost(t *testing.T) {
69
69
assert .Equal (t , "content" , rel .Note )
70
70
})
71
71
72
- t .Run ("ReleaseExistsDoUpdate" , func (t * testing.T ) {
73
- post (t , forms.NewReleaseForm {
72
+ t .Run ("ReleaseExistsDoUpdate(non-tag) " , func (t * testing.T ) {
73
+ ctx := post (t , forms.NewReleaseForm {
74
74
TagName : "v1.1" ,
75
75
Target : "master" ,
76
76
Title : "updated-title" ,
77
77
Content : "updated-content" ,
78
78
})
79
79
rel := loadRelease (t , "v1.1" )
80
80
require .NotNil (t , rel )
81
+ assert .False (t , rel .IsTag )
82
+ assert .Equal (t , "testing-release" , rel .Title )
83
+ assert .NotEmpty (t , ctx .Flash .ErrorMsg )
84
+ })
85
+
86
+ t .Run ("ReleaseExistsDoUpdate(tag-only)" , func (t * testing.T ) {
87
+ ctx := post (t , forms.NewReleaseForm {
88
+ TagName : "delete-tag" , // a strange name, but it is the only "is_tag=true" fixture
89
+ Target : "master" ,
90
+ Title : "updated-title" ,
91
+ Content : "updated-content" ,
92
+ TagOnly : true ,
93
+ })
94
+ rel := loadRelease (t , "delete-tag" )
95
+ require .NotNil (t , rel )
96
+ assert .True (t , rel .IsTag ) // the record should not be updated because the request is "tag-only". TODO: need to improve the logic?
97
+ assert .Equal (t , "delete-tag" , rel .Title )
98
+ assert .NotEmpty (t , ctx .Flash .ErrorMsg )
99
+ })
100
+
101
+ t .Run ("ReleaseExistsDoUpdate(tag-release)" , func (t * testing.T ) {
102
+ ctx := post (t , forms.NewReleaseForm {
103
+ TagName : "delete-tag" , // a strange name, but it is the only "is_tag=true" fixture
104
+ Target : "master" ,
105
+ Title : "updated-title" ,
106
+ Content : "updated-content" ,
107
+ })
108
+ rel := loadRelease (t , "delete-tag" )
109
+ require .NotNil (t , rel )
110
+ assert .False (t , rel .IsTag ) // the tag has been "updated" to be a real "release"
81
111
assert .Equal (t , "updated-title" , rel .Title )
82
- assert .Equal (t , "updated-content" , rel . Note )
112
+ assert .Empty (t , ctx . Flash . ErrorMsg )
83
113
})
84
114
85
115
t .Run ("TagOnly" , func (t * testing.T ) {
0 commit comments