MCPcopy Create free account
hub / github.com/gogs/gogs / setupDBToDump

Function setupDBToDump

internal/database/backup_test.go:44–201  ·  view source on GitHub ↗
(t *testing.T, db *gorm.DB)

Source from the content-addressed store, hash-verified

42}
43
44func setupDBToDump(t *testing.T, db *gorm.DB) {
45 vals := []any{
46 &Access{
47 ID: 1,
48 UserID: 1,
49 RepoID: 11,
50 Mode: AccessModeRead,
51 },
52 &Access{
53 ID: 2,
54 UserID: 2,
55 RepoID: 22,
56 Mode: AccessModeWrite,
57 },
58
59 &AccessToken{
60 UserID: 1,
61 Name: "test1",
62 Sha1: cryptoutil.SHA1("2910d03d-c0b5-4f71-bad5-c4086e4efae3"),
63 SHA256: cryptoutil.SHA256(cryptoutil.SHA1("2910d03d-c0b5-4f71-bad5-c4086e4efae3")),
64 CreatedUnix: 1588568886,
65 UpdatedUnix: 1588572486, // 1 hour later
66 },
67 &AccessToken{
68 UserID: 1,
69 Name: "test2",
70 Sha1: cryptoutil.SHA1("84117e17-7e67-4024-bd04-1c23e6e809d4"),
71 SHA256: cryptoutil.SHA256(cryptoutil.SHA1("84117e17-7e67-4024-bd04-1c23e6e809d4")),
72 CreatedUnix: 1588568886,
73 },
74 &AccessToken{
75 UserID: 2,
76 Name: "test1",
77 Sha1: cryptoutil.SHA1("da2775ce-73dd-47ba-b9d2-bbcc346585c4"),
78 SHA256: cryptoutil.SHA256(cryptoutil.SHA1("da2775ce-73dd-47ba-b9d2-bbcc346585c4")),
79 CreatedUnix: 1588568886,
80 },
81 &AccessToken{
82 UserID: 2,
83 Name: "test2",
84 Sha1: cryptoutil.SHA256(cryptoutil.SHA1("1b2dccd1-a262-470f-bb8c-7fc73192e9bb"))[:40],
85 SHA256: cryptoutil.SHA256(cryptoutil.SHA1("1b2dccd1-a262-470f-bb8c-7fc73192e9bb")),
86 CreatedUnix: 1588568886,
87 },
88
89 &Action{
90 ID: 1,
91 UserID: 1,
92 OpType: ActionCreateBranch,
93 ActUserID: 1,
94 ActUserName: "alice",
95 RepoID: 1,
96 RepoUserName: "alice",
97 RepoName: "example",
98 RefName: "main",
99 IsPrivate: false,
100 Content: `{"Len":1,"Commits":[],"CompareURL":""}`,
101 CreatedUnix: 1588568886,

Callers 1

TestDumpAndImportFunction · 0.85

Calls 5

SHA1Function · 0.92
SHA256Function · 0.92
NewProviderFunction · 0.92
NewProviderFunction · 0.92
CreateMethod · 0.45

Tested by

no test coverage detected