Exemplo n.º 1
0
func main() {
	client := client.New("http://challenge.teespring.com", "1ab087b1-0518-403c-a328-d6350db4d94f")
	question, err := client.FetchQuestion()
	if err != nil {
		panic(err)
	}

	fmt.Printf("Q -> %#v\n", question)

	inks, err := client.FetchInks()
	if err != nil {
		panic(err)
	}

	solver := challenge.NewSolver(inks, question)
	solution := solver.Solve()

	fmt.Printf("S -> %#v\n", solution)

	resp, err := client.PostAnswer(solution)
	if err != nil {
		panic(err)
	}

	fmt.Println("Response to solution:")
	fmt.Println(resp)
}
Exemplo n.º 2
0
	var request *http.Request

	BeforeEach(func() {
		request = nil
		authToken = uuid.New()
	})

	AfterEach(func() {
		server.Close()
	})

	JustBeforeEach(func() {
		server = httptest.NewServer(http.HandlerFunc(serverHandler))

		baseUrl = server.URL
		tClient = client.New(baseUrl, authToken)
	})

	Describe("FetchInks", func() {
		var inks challenge.Inks

		BeforeEach(func() {
			serverHandler = func(w http.ResponseWriter, r *http.Request) {
				request = r
				fmt.Fprintf(w, `{
					"inks": [
					{
						"id": "VN1348",
						"color": "#17B0D8",
						"cost": 12.39
					}