Skip to content
Permalink
Browse files

Changed parameter of set status to take api token as well

  • Loading branch information...
kiriappeee committed Mar 21, 2018
1 parent d4b99e5 commit 21ff0b61abc4fd542b9d554da0bfd2676fc197a9
Showing with 8 additions and 7 deletions.
  1. +3 −2 apiwrapper.go
  2. +2 −2 setstatus.go
  3. +3 −3 setstatus_test.go
@@ -1,7 +1,8 @@
package ssucore

type UpdateStatus func(*Status) (string, error)

func UpdateStatusViaSDK(s *Status) (string, error) {
type UpdateStatus func(*Status, string) (string, error)

func UpdateStatusViaSDK(s *Status, apiToken string) (string, error) {
return "something", nil
}
@@ -42,6 +42,6 @@ func ConvertTextToStructArray(textToConvert string) ([]Status, error) {
return statusesToReturn, nil
}

func (s *Status) setMyStatus(fn UpdateStatus) (string, error) {
return fn(s)
func (s *Status) setMyStatus(fn UpdateStatus, apiToken string) (string, error) {
return fn(s, apiToken)
}
@@ -6,7 +6,7 @@ import (
"errors"
)

func updateStatusViaAPIMock(s *Status) (string, error){
func updateStatusViaAPIMock(s *Status, apiToken string) (string, error){
if s.StatusName == "lunch" && s.Emoji == "chompy" && s.StatusText == "Having lunch"{
return "Status was successfully changed", nil
} else {
@@ -212,7 +212,7 @@ func TestAnErrorIsThrownWhenADuplicateValueExists(t *testing.T){

func TestSetStatusMethodIsCalled(t *testing.T){
s := Status{"lunch", "chompy", "Having lunch"}
result, err := s.setMyStatus(updateStatusViaAPIMock)
result, err := s.setMyStatus(updateStatusViaAPIMock, "mytoken")
if err != nil {
t.Fatalf("Error was not nil. Received: %s", err.Error())
}
@@ -221,7 +221,7 @@ func TestSetStatusMethodIsCalled(t *testing.T){
}

s = Status{"lunch", "chompy", "eating"}
result, err = s.setMyStatus(updateStatusViaAPIMock)
result, err = s.setMyStatus(updateStatusViaAPIMock, "mytoken")
if err == nil {
t.Fatalf("Error was nil. Expected an error")
}

0 comments on commit 21ff0b6

Please sign in to comment.
You can’t perform that action at this time.