You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by mi...@apache.org on 2018/07/11 01:19:48 UTC
[trafficcontrol] 01/13: fixed import conflicts
This is an automated email from the ASF dual-hosted git repository.
mitchell852 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git
commit b6e0971ffd1e1ed2da981da5f1c7a7620c300d35
Author: Dewayne Richardson <de...@apache.org>
AuthorDate: Mon Jun 25 06:58:27 2018 -0600
fixed import conflicts
---
lib/go-tc/v13/staticdnsentry.go | 108 +++++++++++++++++++++
.../staticdnsentry/staticdnsentry_test.go | 86 ++++++++++++++++
2 files changed, 194 insertions(+)
diff --git a/lib/go-tc/v13/staticdnsentry.go b/lib/go-tc/v13/staticdnsentry.go
new file mode 100644
index 0000000..a3da4f7
--- /dev/null
+++ b/lib/go-tc/v13/staticdnsentry.go
@@ -0,0 +1,108 @@
+package v13
+
+import tc "github.com/apache/trafficcontrol/lib/go-tc"
+
+/*
+ * 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
+ *
+ * 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.
+ */
+
+// StatisDNSEntry ...
+type StaticDNSEntry struct {
+
+ // The static IP Address or fqdn of the static dns entry
+ //
+ // required: true
+ Address string `json:"address" db:"address"`
+
+ // The Cachegroup associated
+ //
+ CacheGroup string `json:"cachegroup" db:"cachegroup"`
+
+ // The DeliveryService associated
+ //
+ // required: true
+ DeliveryService string `json:"deliveryservice" db:"dsname"`
+
+ // The host of the static dns entry
+ //
+ // required: true
+ Host string `json:"host" db:"host"`
+
+ // ID of the StaticDNSEntry
+ //
+ // required: true
+ ID int `json:"id" db:"id"`
+
+ // LastUpdated
+ //
+ LastUpdated tc.TimeNoMod `json:"lastUpdated" db:"last_updated"`
+
+ // The Time To Live for the static dns entry
+ //
+ // required: true
+ TTL int64 `json:"ttl" db:"ttl"`
+
+ // The type of the static DNS entry
+ //
+ // required: true
+ // enum: ["A_RECORD", "CNAME_RECORD"]
+ Type string `json:"type" db:"type"`
+}
+
+// StatisDNSEntryNullable ...
+type StaticDNSEntryNullable struct {
+
+ // The static IP Address or fqdn of the static dns entry
+ //
+ // required: true
+ Address *string `json:"address" db:"address"`
+
+ // The Cachegroup associated
+ //
+ CacheGroup *string `json:"cachegroup" db:"cachegroup"`
+
+ // The DeliveryService associated
+ //
+ // required: true
+ DeliveryService *string `json:"deliveryservice" db:"dsname"`
+
+ // The host of the static dns entry
+ //
+ // required: true
+ Host *string `json:"host" db:"host"`
+
+ // ID of the StaticDNSEntry
+ //
+ // required: true
+ ID *int `json:"id" db:"id"`
+
+ // LastUpdated
+ //
+ LastUpdated *tc.TimeNoMod `json:"lastUpdated" db:"last_updated"`
+
+ // The Time To Live for the static dns entry
+ //
+ // required: true
+ TTL *int64 `json:"ttl" db:"ttl"`
+
+ // The type of the static DNS entry
+ //
+ // required: true
+ // enum: ["A_RECORD", "CNAME_RECORD"]
+ Type *string `json:"type" db:"type"`
+}
diff --git a/traffic_ops/traffic_ops_golang/staticdnsentry/staticdnsentry_test.go b/traffic_ops/traffic_ops_golang/staticdnsentry/staticdnsentry_test.go
new file mode 100644
index 0000000..9597758
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/staticdnsentry/staticdnsentry_test.go
@@ -0,0 +1,86 @@
+package staticdnsentry
+
+/*
+ * 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
+ *
+ * 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.
+ */
+
+import (
+ "errors"
+ "reflect"
+ "strings"
+ "testing"
+
+ "github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/api"
+ "github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/test"
+)
+
+func TestFuncs(t *testing.T) {
+ if strings.Index(selectQuery(), "SELECT") != 0 {
+ t.Errorf("expected selectQuery to start with SELECT")
+ }
+ if strings.Index(insertQuery(), "INSERT") != 0 {
+ t.Errorf("expected insertQuery to start with INSERT")
+ }
+ if strings.Index(updateQuery(), "UPDATE") != 0 {
+ t.Errorf("expected updateQuery to start with UPDATE")
+ }
+ if strings.Index(deleteQuery(), "DELETE") != 0 {
+ t.Errorf("expected deleteQuery to start with DELETE")
+ }
+
+}
+
+func TestInterfaces(t *testing.T) {
+ var i interface{}
+ i = &TOStaticDNSEntry{}
+
+ if _, ok := i.(api.Creator); !ok {
+ t.Errorf("staticDNSEntry must be creator")
+ }
+ if _, ok := i.(api.Reader); !ok {
+ t.Errorf("staticDNSEntry must be reader")
+ }
+ if _, ok := i.(api.Updater); !ok {
+ t.Errorf("staticDNSEntry must be updater")
+ }
+ if _, ok := i.(api.Deleter); !ok {
+ t.Errorf("staticDNSEntry must be deleter")
+ }
+ if _, ok := i.(api.Identifier); !ok {
+ t.Errorf("staticDNSEntry must be Identifier")
+ }
+}
+
+func TestValidate(t *testing.T) {
+ // invalid name, empty domainname
+ ts := TOStaticDNSEntry{}
+ errs := test.SortErrors(ts.Validate(nil))
+
+ expectedErrs := []error{
+ errors.New(`'address' cannot be blank`),
+ errors.New(`'dsname' cannot be blank`),
+ errors.New(`'host' cannot be blank`),
+ errors.New(`'ttl' cannot be blank`),
+ errors.New(`'type' cannot be blank`),
+ }
+
+ if !reflect.DeepEqual(expectedErrs, errs) {
+ t.Errorf("expected %s, got %s", expectedErrs, errs)
+ }
+
+}