Skip to content
Snippets Groups Projects
Unverified Commit 2b13bdd1 authored by Daniel Dao's avatar Daniel Dao
Browse files

storage: fix list connector test

The previous test doesnt actually testing ListConnectors code. For
example the following pseudocode will pass the test:

```
ListConnectors() { return nil, nil }
```

Instead change to actually fetch and compare list of connectors,
ordering by name
parent 3d65b774
No related branches found
No related tags found
No related merge requests found
...@@ -628,9 +628,21 @@ func testConnectorCRUD(t *testing.T, s storage.Storage) { ...@@ -628,9 +628,21 @@ func testConnectorCRUD(t *testing.T, s storage.Storage) {
c1.Type = "oidc" c1.Type = "oidc"
getAndCompare(id1, c1) getAndCompare(id1, c1)
if _, err := s.ListConnectors(); err != nil { connectorList := []storage.Connector{c1, c2}
t.Fatalf("failed to list connectors: %v", err) listAndCompare := func(want []storage.Connector) {
connectors, err := s.ListConnectors()
if err != nil {
t.Errorf("list connectors: %v", err)
return
}
sort.Slice(connectors, func(i, j int) bool {
return connectors[i].Name < connectors[j].Name
})
if diff := pretty.Compare(want, connectors); diff != "" {
t.Errorf("password list retrieved from storage did not match: %s", diff)
}
} }
listAndCompare(connectorList)
if err := s.DeleteConnector(c1.ID); err != nil { if err := s.DeleteConnector(c1.ID); err != nil {
t.Fatalf("failed to delete connector: %v", err) t.Fatalf("failed to delete connector: %v", err)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment