File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -102,3 +102,37 @@ func TestGihubReleaser_errorOnBadJSON(t *testing.T) {
102102 t .Error ("expected error but got none" )
103103 }
104104}
105+
106+ type etagTransport struct {}
107+
108+ func (etagTransport ) RoundTrip (r * http.Request ) (* http.Response , error ) {
109+ if r .Header .Get ("If-None-Match" ) != `"some-etag"` {
110+ return nil , errors .New ("expected etag" )
111+ }
112+
113+ resp := & http.Response {
114+ StatusCode : http .StatusNotModified ,
115+ }
116+ return resp , nil
117+ }
118+
119+ func TestGihubReleaser_supportsEtag (t * testing.T ) {
120+ ctx := context .Background ()
121+ ghr := & impl.GitHubReleaser {
122+ URL : "http://github.com/repos/you/your-app/releases" ,
123+ Client : & http.Client {
124+ Transport : etagTransport {},
125+ },
126+ }
127+ etag := `"some-etag"`
128+ rels , outEtag , err := ghr .Get (ctx , etag )
129+ if err != nil {
130+ t .Error ("unexpected error:" , err )
131+ }
132+ if len (rels ) != 0 {
133+ t .Error ("expected no rels but got some" )
134+ }
135+ if outEtag != etag {
136+ t .Error ("incorrect etag. wanted:" , etag , "got:" , outEtag )
137+ }
138+ }
You can’t perform that action at this time.
0 commit comments