Skip to content

Commit 9b5f3c4

Browse files
authored
Merge pull request #485 from meshery/feat/meshsync
feat: Add test for meshsync
2 parents b0b57ca + e844035 commit 9b5f3c4

File tree

4 files changed

+78
-3
lines changed

4 files changed

+78
-3
lines changed

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,8 @@ catalog-push: ## Push a catalog image.
270270
$(MAKE) docker-push IMG=$(CATALOG_IMG)
271271

272272
# Test coverage
273-
.PHONY: coverage
274-
coverage: ## Generate test coverage report
273+
.PHONY: coverage
274+
coverage: test-env
275275
go test -v ./... -coverprofile cover.out
276276
go tool cover -html=cover.out -o cover.html
277277

@@ -295,4 +295,4 @@ $(BIN_DIR)/setup-envtest-$(SETUP_ENVTEST_VERSION):
295295
.PHONY: test-env
296296
test-env:
297297
make bin/setup-envtest
298-
bin//setup-envtest use $(ENVTEST_K8S_VERSION) --bin-dir $(BIN_DIR)
298+
bin/setup-envtest use $(ENVTEST_K8S_VERSION) --bin-dir $(BIN_DIR)

pkg/meshsync/meshsync.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
Copyright 2023 Layer5, Inc.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
117
package meshsync
218

319
import (

pkg/meshsync/meshsync_test.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
Copyright 2023 Layer5, Inc.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package meshsync
18+
19+
import (
20+
"testing"
21+
22+
mesheryv1alpha1 "github.com/layer5io/meshery-operator/api/v1alpha1"
23+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
24+
)
25+
26+
func TestGetObjects(t *testing.T) {
27+
m := &mesheryv1alpha1.MeshSync{
28+
ObjectMeta: metav1.ObjectMeta{
29+
Name: "test",
30+
Namespace: "test",
31+
},
32+
Spec: mesheryv1alpha1.MeshSyncSpec{
33+
Size: 1,
34+
},
35+
}
36+
obj := GetObjects(m)
37+
if obj == nil {
38+
t.Error("GetObjects returned nil")
39+
}
40+
if obj[ServerObject] == nil {
41+
t.Error("GetObjects returned nil for server object")
42+
}
43+
}

pkg/meshsync/resources.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
Copyright 2023 Layer5, Inc.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
117
package meshsync
218

319
import (

0 commit comments

Comments
 (0)