-
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
In some cases, static user data is sufficient and changes to the users do not need to be persisted. This change introduces a special file path `:memory:` (similar to sqlite3) that allows the user to specify that the database is in-memory only. Changes will not be persisted on the file system.
- Loading branch information
Showing
2 changed files
with
35 additions
and
9 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
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 |
---|---|---|
|
@@ -16,14 +16,15 @@ package identity | |
|
||
import ( | ||
"fmt" | ||
"github.com/google/go-cmp/cmp" | ||
"github.com/greenpau/go-authcrunch/internal/tests" | ||
"github.com/greenpau/go-authcrunch/pkg/errors" | ||
"github.com/greenpau/go-authcrunch/pkg/requests" | ||
"path" | ||
"path/filepath" | ||
"testing" | ||
"time" | ||
|
||
"github.com/google/go-cmp/cmp" | ||
"github.com/greenpau/go-authcrunch/internal/tests" | ||
"github.com/greenpau/go-authcrunch/pkg/errors" | ||
"github.com/greenpau/go-authcrunch/pkg/requests" | ||
) | ||
|
||
var ( | ||
|
@@ -117,6 +118,24 @@ func TestNewDatabase(t *testing.T) { | |
"user_count": 0, | ||
}, | ||
}, | ||
{ | ||
name: "test create new in-memory database", | ||
path: ":memory:", | ||
req: &requests.Request{ | ||
User: requests.User{ | ||
Username: "jsmith", | ||
Password: passwd, | ||
Email: "[email protected]", | ||
FullName: "Smith, John", | ||
Roles: []string{"viewer", "editor", "admin"}, | ||
}, | ||
}, | ||
backup: filepath.Join(tmpDir, "user_db_backup.json"), | ||
want: map[string]interface{}{ | ||
"path": ":memory:", | ||
"user_count": 0, | ||
}, | ||
}, | ||
{ | ||
name: "test new database is directory", | ||
path: tmpDir, | ||
|