forked from forgejo/forgejo
Queue: Add generic graceful queues with settings
This commit is contained in:
parent
b983ff4473
commit
85042634fc
15 changed files with 1466 additions and 0 deletions
42
modules/queue/queue_test.go
Normal file
42
modules/queue/queue_test.go
Normal file
|
@ -0,0 +1,42 @@
|
|||
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package queue
|
||||
|
||||
import "testing"
|
||||
|
||||
import "github.com/stretchr/testify/assert"
|
||||
|
||||
import "encoding/json"
|
||||
|
||||
type testData struct {
|
||||
TestString string
|
||||
TestInt int
|
||||
}
|
||||
|
||||
func TestToConfig(t *testing.T) {
|
||||
cfg := testData{
|
||||
TestString: "Config",
|
||||
TestInt: 10,
|
||||
}
|
||||
exemplar := testData{}
|
||||
|
||||
cfg2I, err := toConfig(exemplar, cfg)
|
||||
assert.NoError(t, err)
|
||||
cfg2, ok := (cfg2I).(testData)
|
||||
assert.True(t, ok)
|
||||
assert.NotEqual(t, cfg2, exemplar)
|
||||
assert.Equal(t, &cfg, &cfg2)
|
||||
|
||||
cfgString, err := json.Marshal(cfg)
|
||||
assert.NoError(t, err)
|
||||
|
||||
cfg3I, err := toConfig(exemplar, cfgString)
|
||||
assert.NoError(t, err)
|
||||
cfg3, ok := (cfg3I).(testData)
|
||||
assert.True(t, ok)
|
||||
assert.Equal(t, cfg.TestString, cfg3.TestString)
|
||||
assert.Equal(t, cfg.TestInt, cfg3.TestInt)
|
||||
assert.NotEqual(t, cfg3, exemplar)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue