File: mirror_test.go

package info (click to toggle)
aptly 1.5.0%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 48,840 kB
  • sloc: python: 7,966; sh: 798; makefile: 81
file content (40 lines) | stat: -rw-r--r-- 1,041 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package api

import (
	"bytes"
	"encoding/json"

	"github.com/gin-gonic/gin"
	. "gopkg.in/check.v1"
)

type MirrorSuite struct {
	ApiSuite
}

var _ = Suite(&MirrorSuite{})

func (s *MirrorSuite) TestGetMirrors(c *C) {
	response, _ := s.HTTPRequest("GET", "/api/mirrors", nil)
	c.Check(response.Code, Equals, 200)
	c.Check(response.Body.String(), Equals, "[]")
}

func (s *MirrorSuite) TestDeleteMirrorNonExisting(c *C) {
	response, _ := s.HTTPRequest("DELETE", "/api/mirrors/does-not-exist", nil)
	c.Check(response.Code, Equals, 404)
	c.Check(response.Body.String(), Equals, "{\"error\":\"unable to drop: mirror with name does-not-exist not found\"}")
}

func (s *MirrorSuite) TestCreateMirror(c *C) {
	c.ExpectFailure("Need to mock downloads")
	body, err := json.Marshal(gin.H{
		"Name":       "dummy",
		"ArchiveURL": "foobar",
	})
	c.Assert(err, IsNil)
	response, err := s.HTTPRequest("POST", "/api/mirrors", bytes.NewReader(body))
	c.Assert(err, IsNil)
	c.Check(response.Code, Equals, 400)
	c.Check(response.Body.String(), Equals, "")
}