Skip to content

Commit

Permalink
chore: more UTs for some pkgs (#6017)
Browse files Browse the repository at this point in the history
  • Loading branch information
csuzhangxc authored Dec 30, 2024
1 parent 3e7945d commit 7a1150d
Show file tree
Hide file tree
Showing 20 changed files with 1,424 additions and 71 deletions.
37 changes: 37 additions & 0 deletions pkg/timanager/apis/pd/v1/types_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright 2024 PingCAP, Inc.
//
// 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 v1

import (
"testing"

"github.com/stretchr/testify/assert"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

func TestEngine(t *testing.T) {
// we only have two engines now, TiKV and TiFlash
s1 := Store{}
assert.Equal(t, StoreEngine("tikv"), s1.Engine())

s2 := Store{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{
"engine": "tiflash",
},
},
}
assert.Equal(t, StoreEngine("tiflash"), s2.Engine())
}
2 changes: 1 addition & 1 deletion pkg/timanager/pd/pd.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func CacheKeys(pdg *v1alpha1.PDGroup) ([]string, error) {
return keys, nil
}

func NewUnderlayClientFunc(c client.Client) timanager.NewUnderlayClientFunc[*v1alpha1.PDGroup, pdapi.PDClient] {
var NewUnderlayClientFunc = func(c client.Client) timanager.NewUnderlayClientFunc[*v1alpha1.PDGroup, pdapi.PDClient] {
return func(pdg *v1alpha1.PDGroup) (pdapi.PDClient, error) {
ctx := context.Background()
var cluster v1alpha1.Cluster
Expand Down
Loading

0 comments on commit 7a1150d

Please sign in to comment.