Skip to content
quarry Artifact [ef3f82e9ba]
Login

Artifact [ef3f82e9ba]

Artifact ef3f82e9ba5395b1144a8aae8e5c8928dd056cf6653f6b9ce9188837d5a25bf4:


package main

import (
	"path/filepath"
	"testing"

	"craftdesign.group/quarry/internal/oltp"
)

// RFC 0021: no new hand-issued sync_user row can be made. `quarry user
// add` refuses, before it opens anything, and leaves the store as it was.
func TestUserAddIssuesNoSyncUser(t *testing.T) {
	dir := t.TempDir()
	if err := userCmd([]string{"add", "--repo", "alpha=" + t.TempDir(), "--user", "jan", "--password", "pw-jan-123", "--data", dir}); err == nil {
		t.Fatal("FAIL: user add succeeded")
	}
	db, err := oltp.Open(filepath.Join(dir, "oltp.db"))
	if err != nil {
		t.Fatal(err)
	}
	defer db.Close()
	if repos, _ := db.LegacySyncUsers("jan"); len(repos) != 0 {
		t.Errorf("FAIL: user add wrote sync_user rows: %v", repos)
	} else {
		t.Log("ok: user add refused and wrote nothing")
	}
}