Пример #1
0
func main() {
	app := cli.NewApp()
	app.Name = "gumshoe"
	app.Usage = "talks to tracker"

	config := trackerapi.NewConfiguration()
	client, err := trackerapi.NewClient(config)
	if err != nil {
		panic(err)
	}
	terminal := term.New()
	app.Commands = []cli.Command{
		{
			Name:  "me",
			Usage: "prints out Tracker's representation of your account",
			Action: func(c *cli.Context) {
				handleAuthentication(client, terminal)
				output := client.Me()
				fmt.Println(output)
			},
		},
		{
			Name:  "projects",
			Usage: "prints out a list of Tracker projects for your account",
			Action: func(c *cli.Context) {
				handleAuthentication(client, terminal)
				output := client.Projects()
				fmt.Println(output)
			},
		},
		{
			Name:  "activity",
			Usage: "lists last 5 activities for a given project",
			Action: func(c *cli.Context) {
				if len(c.Args()) == 0 {
					fmt.Println("Please supply a project ID")
					os.Exit(1)
				}
				projectID, err := strconv.Atoi(c.Args()[0])
				if err != nil {
					fmt.Println("Something went wrong parsing the Project ID.", err)
					os.Exit(1)
				}
				handleAuthentication(client, terminal)
				output := client.Activity(projectID)
				fmt.Println(output)
			},
		},
	}

	app.Run(os.Args)
}
Пример #2
0
	"github.com/pivotal/gumshoe/trackerapi/request"
	"github.com/pivotal/gumshoe/trackerapi/store"
)

var _ = Describe("Client", func() {
	var (
		json   string
		client *trackerapi.Client
		ts     *TestServer
	)

	BeforeEach(func() {
		config := trackerapi.NewConfiguration()
		config.Store = store.NewMemoryStore()
		config.Store.Set("APIToken", "abcde90792f3898ab464cd3412345")
		client, _ = trackerapi.NewClient(config)
	})

	AfterEach(func() {
		client.Cleanup()
		ts.Close()
	})

	Describe("Me", func() {
		BeforeEach(func() {
			json = `{
                "api_token": "abcde90792f3898ab464cd3412345",
                "name": "Mister Tee",
                "kind": "me",
                "id": 123,
                "email": "*****@*****.**",