mirror of
https://github.com/hanzoai/forge.git
synced 2026-10-30 15:00:39 +00:00
Source files keep their SPDX-License-Identifier and Hanzo copyright line; the Gitea, Gogs and LFS Test Server copyrights they used to repeat now live once in NOTICE, alongside LICENSE. The header lint accepts any copyright line above the SPDX line, so it no longer demands an upstream one. Co-authored-by: Hanzo Dev <[email protected]>
44 lines
1.3 KiB
Go
44 lines
1.3 KiB
Go
// Copyright 2026 Hanzo AI, Inc. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package v1_22
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/hanzoai/git/models/migrations/migrationtest"
|
|
"github.com/hanzoai/git/models/project"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func Test_CheckProjectColumnsConsistency(t *testing.T) {
|
|
// Prepare and load the testing database
|
|
x, deferable := migrationtest.PrepareTestEnv(t, 0, new(project.Project), new(project.Column))
|
|
defer deferable()
|
|
if x == nil || t.Failed() {
|
|
return
|
|
}
|
|
|
|
assert.NoError(t, CheckProjectColumnsConsistency(x))
|
|
|
|
// check if default column was added
|
|
var defaultColumn project.Column
|
|
has, err := x.Where("project_id=? AND `default` = ?", 1, true).Get(&defaultColumn)
|
|
assert.NoError(t, err)
|
|
assert.True(t, has)
|
|
assert.Equal(t, int64(1), defaultColumn.ProjectID)
|
|
assert.True(t, defaultColumn.Default)
|
|
|
|
// check if multiple defaults, previous were removed and last will be kept
|
|
expectDefaultColumn, err := project.GetColumn(t.Context(), 2)
|
|
assert.NoError(t, err)
|
|
assert.Equal(t, int64(2), expectDefaultColumn.ProjectID)
|
|
assert.False(t, expectDefaultColumn.Default)
|
|
|
|
expectNonDefaultColumn, err := project.GetColumn(t.Context(), 3)
|
|
assert.NoError(t, err)
|
|
assert.Equal(t, int64(2), expectNonDefaultColumn.ProjectID)
|
|
assert.True(t, expectNonDefaultColumn.Default)
|
|
}
|