-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: create firestore session test assertion
- Loading branch information
Showing
6 changed files
with
108 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,4 +12,5 @@ type Engine interface { | |
CertificateStore | ||
OcpiStore | ||
LocationStore | ||
SessionStore | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package firestore | ||
|
||
import ( | ||
"context" | ||
"github.com/thoughtworks/maeve-csms/manager/store" | ||
) | ||
|
||
func (s *Store) SetSession(ctx context.Context, session *store.Session) error { | ||
|
||
return nil | ||
} | ||
|
||
func (s *Store) LookupSession(ctx context.Context, sessionId string) (*store.Session, error) { | ||
return nil, nil | ||
} | ||
|
||
func (s *Store) ListSessions(context context.Context, offset int, limit int) ([]*store.Session, error) { | ||
return nil, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
//go:build integration | ||
|
||
package firestore_test | ||
|
||
import ( | ||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
"github.com/thoughtworks/maeve-csms/manager/store" | ||
"github.com/thoughtworks/maeve-csms/manager/store/firestore" | ||
"golang.org/x/net/context" | ||
"k8s.io/utils/clock" | ||
"testing" | ||
) | ||
|
||
func TestSetAndLookupSession(t *testing.T) { | ||
defer cleanupAllCollections(t, "myproject") | ||
|
||
ctx := context.Background() | ||
sessionStore, err := firestore.NewStore(ctx, "myproject", clock.RealClock{}) | ||
require.NoError(t, err) | ||
|
||
want := &store.Session{ | ||
CountryCode: "BEL", | ||
PartyId: "TWK", | ||
Id: "s001", | ||
StartDateTime: "", //Look at | ||
EndDateTime: "", | ||
Kwh: 5, | ||
CdrToken: store.CdrToken{ | ||
ContractId: "GBTWK012345678V", | ||
Type: "RFID", | ||
Uid: "MYRFIDTAG", | ||
}, | ||
AuthMethod: "AUTH_REQUEST", //may cause issue | ||
Currency: "GBP", | ||
Status: "ACTIVE", | ||
LastUpdated: "2019-08-24T14:15:22Z", | ||
} | ||
err = sessionStore.SetSession(ctx, want) | ||
require.NoError(t, err) | ||
|
||
got, err := sessionStore.LookupSession(ctx, "s001") | ||
require.NoError(t, err) | ||
|
||
//assert.Regexp(t, `^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z`) | ||
|
||
assert.Equal(t, want, got) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters