You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by sr...@apache.org on 2023/05/17 12:05:14 UTC
[plc4x] 03/04: fix(plc4go/spi): gracefully handle tag names not found on DefaultTag
This is an automated email from the ASF dual-hosted git repository.
sruehl pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git
commit fdce5b9aa7fafe83f85c9db794fe4b826f0d35e0
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Wed May 17 13:59:43 2023 +0200
fix(plc4go/spi): gracefully handle tag names not found on DefaultTag
---
plc4go/spi/model/DefaultPlcTagRequest_test.go | 133 ++++++++++++++++++++++++++
1 file changed, 133 insertions(+)
diff --git a/plc4go/spi/model/DefaultPlcTagRequest_test.go b/plc4go/spi/model/DefaultPlcTagRequest_test.go
new file mode 100644
index 0000000000..6ac7c6daaf
--- /dev/null
+++ b/plc4go/spi/model/DefaultPlcTagRequest_test.go
@@ -0,0 +1,133 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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
+ *
+ * https://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 model
+
+import (
+ "testing"
+
+ apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
+
+ "github.com/stretchr/testify/assert"
+)
+
+func TestDefaultPlcTagRequest_GetTag(t *testing.T) {
+ type fields struct {
+ tags map[string]apiModel.PlcTag
+ tagNames []string
+ }
+ type args struct {
+ name string
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ want apiModel.PlcTag
+ }{
+ {
+ name: "get it (not found)",
+ },
+ {
+ name: "get it",
+ fields: fields{
+ tags: map[string]apiModel.PlcTag{
+ "something": nil,
+ },
+ },
+ args: args{
+ name: "something",
+ },
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ d := &DefaultPlcTagRequest{
+ tags: tt.fields.tags,
+ tagNames: tt.fields.tagNames,
+ }
+ assert.Equalf(t, tt.want, d.GetTag(tt.args.name), "GetTag(%v)", tt.args.name)
+ })
+ }
+}
+
+func TestDefaultPlcTagRequest_GetTagNames(t *testing.T) {
+ type fields struct {
+ tags map[string]apiModel.PlcTag
+ tagNames []string
+ }
+ tests := []struct {
+ name string
+ fields fields
+ want []string
+ }{
+ // TODO: Add test cases.
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ d := &DefaultPlcTagRequest{
+ tags: tt.fields.tags,
+ tagNames: tt.fields.tagNames,
+ }
+ assert.Equalf(t, tt.want, d.GetTagNames(), "GetTagNames()")
+ })
+ }
+}
+
+func TestDefaultPlcTagRequest_IsAPlcMessage(t *testing.T) {
+ type fields struct {
+ tags map[string]apiModel.PlcTag
+ tagNames []string
+ }
+ tests := []struct {
+ name string
+ fields fields
+ want bool
+ }{
+ // TODO: Add test cases.
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ d := &DefaultPlcTagRequest{
+ tags: tt.fields.tags,
+ tagNames: tt.fields.tagNames,
+ }
+ assert.Equalf(t, tt.want, d.IsAPlcMessage(), "IsAPlcMessage()")
+ })
+ }
+}
+
+func TestNewDefaultPlcTagRequest(t *testing.T) {
+ type args struct {
+ tags map[string]apiModel.PlcTag
+ tagNames []string
+ }
+ tests := []struct {
+ name string
+ args args
+ want *DefaultPlcTagRequest
+ }{
+ // TODO: Add test cases.
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ assert.Equalf(t, tt.want, NewDefaultPlcTagRequest(tt.args.tags, tt.args.tagNames), "NewDefaultPlcTagRequest(%v, %v)", tt.args.tags, tt.args.tagNames)
+ })
+ }
+}