-
Notifications
You must be signed in to change notification settings - Fork 2
/
storage_test.go
49 lines (40 loc) · 1.25 KB
/
storage_test.go
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
41
42
43
44
45
46
47
48
49
package main
import (
"errors"
"github.com/AlexsJones/kepler/commands/storage"
"github.com/DATA-DOG/godog"
)
var (
storageRef *storage.Storage
)
func iGetAnInstanceOfStorage() error {
storageRef = storage.GetInstance()
return nil
}
func iAmAbleToValidateThatTheInstanceIsAnInitialisedObject() error {
if storageRef == nil {
return errors.New("Uninitialised storage")
}
return nil
}
func StorageFeatureContext(s *godog.Suite) {
s.Step(`^I get an instance of storage$`, iGetAnInstanceOfStorage)
s.Step(`^I am able to validate that the instance is an initialised object$`, iAmAbleToValidateThatTheInstanceIsAnInitialisedObject)
}
func iWishToStoreAnAccessTokenWithValueOf(arg1 string) error {
storageRef.Github.AccessToken = arg1
return storageRef.Save()
}
func itShouldSaveCorrectly(args1 string) error {
if storage.GetInstance().Github.AccessToken != args1 {
return errors.New("Stored value does not match")
}
return nil
}
func StorageWithDataFeatureContext(s *godog.Suite) {
s.Step(`^I wish to store an Access Token with value of "([^"]*)"$`, iWishToStoreAnAccessTokenWithValueOf)
s.Step(`^it should save correctly with value of "([^"]*)"$`, itShouldSaveCorrectly)
s.BeforeScenario(func(interface{}) {
storageRef = storage.GetInstance()
})
}