Example #1
0
func New(cnf *config.Config) *Wunderground {

	err := cnf.Validate()
	if err != nil {
		panic(err)
	}

	return &Wunderground{
		apiKey:  cnf.ApiKey,
		apiHost: cnf.ApiHost,
		client:  http.DefaultClient,
	}
}
Example #2
0
package wunderground_test

import (
	"github.com/wfernandes/weather/wunderground"

	"fmt"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/wfernandes/weather/wunderground/config"
)

var _ = Describe("Wunderground", func() {

	var (
		apiKey string
		conf   *config.Config
	)

	BeforeEach(func() {
		apiKey = "some_api_key"
		conf = wunderground.DefaultConfig(apiKey)
	})

	Context("Default Config", func() {
		It("sets the api key and defaults for the HttpClient and api host", func() {
			Expect(conf.ApiKey).To(Equal(apiKey))
			Expect(conf.ApiHost).To(Equal("http://api.wunderground.com"))
		})
	})

	Context("Initialization", func() {