mirror of
https://github.com/goharbor/harbor
synced 2025-04-07 16:44:01 +00:00
51 lines
1.3 KiB
Go
51 lines
1.3 KiB
Go
// Copyright (c) 2017 VMware, Inc. All Rights Reserved.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
package trigger
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/vmware/harbor/src/replication"
|
|
)
|
|
|
|
func TestKindOfScheduleTrigger(t *testing.T) {
|
|
trigger := NewScheduleTrigger(ScheduleParam{})
|
|
assert.Equal(t, replication.TriggerKindSchedule, trigger.Kind())
|
|
}
|
|
|
|
func TestParseOfftime(t *testing.T) {
|
|
cases := []struct {
|
|
offtime int64
|
|
hour int
|
|
minite int
|
|
second int
|
|
}{
|
|
{0, 0, 0, 0},
|
|
{1, 0, 0, 1},
|
|
{60, 0, 1, 0},
|
|
{3600, 1, 0, 0},
|
|
{3661, 1, 1, 1},
|
|
{3600*24 + 60, 0, 1, 0},
|
|
}
|
|
|
|
for _, c := range cases {
|
|
h, m, s := parseOfftime(c.offtime)
|
|
assert.Equal(t, c.hour, h)
|
|
assert.Equal(t, c.minite, m)
|
|
assert.Equal(t, c.second, s)
|
|
}
|
|
}
|