Skip to content

Commit

Permalink
feat: add touched fields (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
cgroschupp authored Nov 26, 2024
1 parent ddcd82a commit 03b902e
Show file tree
Hide file tree
Showing 15 changed files with 38 additions and 10 deletions.
1 change: 1 addition & 0 deletions domains.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type Domain struct {
Keys []DomainKey `json:"keys,omitempty"`
Created *time.Time `json:"created,omitempty"`
Published *time.Time `json:"published,omitempty"`
Touched *time.Time `json:"touched,omitempty"`
}

// DomainKey a domain key representation.
Expand Down
5 changes: 5 additions & 0 deletions domains_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ func TestDomainsService_Create(t *testing.T) {
},
Created: mustParseTime("2018-09-18T16:36:16.510368Z"),
Published: mustParseTime("2018-09-18T17:21:38.348112Z"),
Touched: mustParseTime("2018-09-18T17:21:38.348112Z"),
}
assert.Equal(t, expected, newDomain)
}
Expand Down Expand Up @@ -136,6 +137,7 @@ func TestDomainsService_Get(t *testing.T) {
},
Created: mustParseTime("2018-09-18T16:36:16.510368Z"),
Published: mustParseTime("2018-09-18T17:21:38.348112Z"),
Touched: mustParseTime("2018-09-18T17:21:38.348112Z"),
}
assert.Equal(t, expected, domain)
}
Expand Down Expand Up @@ -180,6 +182,7 @@ func TestDomainsService_GetResponsible(t *testing.T) {
MinimumTTL: 3600,
Created: mustParseTime("2022-11-12T18:01:35.454616Z"),
Published: mustParseTime("2022-11-12T18:03:19.516440Z"),
Touched: mustParseTime("2022-11-12T18:03:19.516440Z"),
}
assert.Equal(t, expected, domain)
}
Expand Down Expand Up @@ -243,12 +246,14 @@ func TestDomainsService_GetAll(t *testing.T) {
MinimumTTL: 3600,
Created: mustParseTime("2020-05-13T11:35:40.954616Z"),
Published: mustParseTime("2020-05-13T12:25:19.816440Z"),
Touched: mustParseTime("2020-05-13T12:25:19.816440Z"),
},
{
Name: "example.dedyn.io",
MinimumTTL: 60,
Created: mustParseTime("2020-05-05T23:17:36.101470Z"),
Published: mustParseTime("2020-05-06T12:13:06.138443Z"),
Touched: mustParseTime("2020-05-06T12:13:06.138443Z"),
},
}
assert.Equal(t, expected, domains)
Expand Down
3 changes: 2 additions & 1 deletion fixtures/domains_create.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
],
"minimum_ttl": 3600,
"name": "example.com",
"published": "2018-09-18T17:21:38.348112Z"
"published": "2018-09-18T17:21:38.348112Z",
"touched": "2018-09-18T17:21:38.348112Z"
}
3 changes: 2 additions & 1 deletion fixtures/domains_get.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
],
"minimum_ttl": 3600,
"name": "example.com",
"published": "2018-09-18T17:21:38.348112Z"
"published": "2018-09-18T17:21:38.348112Z",
"touched": "2018-09-18T17:21:38.348112Z"
}
2 changes: 2 additions & 0 deletions fixtures/domains_getall.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
[
{
"created": "2020-05-13T11:35:40.954616Z",
"touched": "2020-05-13T12:25:19.816440Z",
"published": "2020-05-13T12:25:19.816440Z",
"name": "example.org",
"minimum_ttl": 3600
},
{
"created": "2020-05-05T23:17:36.101470Z",
"published": "2020-05-06T12:13:06.138443Z",
"touched": "2020-05-06T12:13:06.138443Z",
"name": "example.dedyn.io",
"minimum_ttl": 60
}
Expand Down
1 change: 1 addition & 0 deletions fixtures/domains_getresponsible.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{
"created": "2022-11-12T18:01:35.454616Z",
"published": "2022-11-12T18:03:19.516440Z",
"touched": "2022-11-12T18:03:19.516440Z",
"name": "dev.example.org",
"minimum_ttl": 3600
}
Expand Down
3 changes: 2 additions & 1 deletion fixtures/records_create.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
"\"txt\""
],
"ttl": 300,
"type": "TXT"
"type": "TXT",
"touched": "2020-05-06T11:46:07.641885Z"
}
3 changes: 2 additions & 1 deletion fixtures/records_create_bulk.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"\"txt\""
],
"ttl": 300,
"type": "TXT"
"type": "TXT",
"touched": "2020-05-06T11:46:07.641885Z"
}
]
3 changes: 2 additions & 1 deletion fixtures/records_get.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
"\"txt\""
],
"ttl": 300,
"type": "TXT"
"type": "TXT",
"touched": "2020-05-06T11:46:07.641885Z"
}
6 changes: 4 additions & 2 deletions fixtures/records_getall.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"10.10.10.10"
],
"ttl": 60,
"type": "A"
"type": "A",
"touched": "2020-05-06T11:46:07.641885Z"
},
{
"created": "2020-05-06T11:46:07.641885Z",
Expand All @@ -20,6 +21,7 @@
"ns2.desec.org."
],
"ttl": 3600,
"type": "NS"
"type": "NS",
"touched": "2020-05-06T11:46:07.641885Z"
}
]
3 changes: 2 additions & 1 deletion fixtures/records_replace.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
"\"updated\""
],
"ttl": 300,
"type": "TXT"
"type": "TXT",
"touched": "2020-05-06T11:46:07.641885Z"
}
3 changes: 2 additions & 1 deletion fixtures/records_update.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
"\"updated\""
],
"ttl": 300,
"type": "TXT"
"type": "TXT",
"touched": "2020-05-06T11:46:07.641885Z"
}
3 changes: 2 additions & 1 deletion fixtures/records_update_bulk.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"\"updated\""
],
"ttl": 300,
"type": "TXT"
"type": "TXT",
"touched": "2020-05-06T11:46:07.641885Z"
}
]
1 change: 1 addition & 0 deletions records.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type RRSet struct {
Records []string `json:"records"`
TTL int `json:"ttl,omitempty"`
Created *time.Time `json:"created,omitempty"`
Touched *time.Time `json:"touched,omitempty"`
}

// RRSetFilter a RRSets filter.
Expand Down
8 changes: 8 additions & 0 deletions records_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ func TestRecordsService_Create(t *testing.T) {
Records: []string{`"txt"`},
TTL: 300,
Created: mustParseTime("2020-05-06T11:46:07.641885Z"),
Touched: mustParseTime("2020-05-06T11:46:07.641885Z"),
}
assert.Equal(t, expected, newRecord)
}
Expand Down Expand Up @@ -127,6 +128,7 @@ func TestRecordsService_Get(t *testing.T) {
Records: []string{`"txt"`},
TTL: 300,
Created: mustParseTime("2020-05-06T11:46:07.641885Z"),
Touched: mustParseTime("2020-05-06T11:46:07.641885Z"),
}
assert.Equal(t, expected, record)
}
Expand Down Expand Up @@ -174,6 +176,7 @@ func TestRecordsService_Update(t *testing.T) {
Records: []string{`"updated"`},
TTL: 300,
Created: mustParseTime("2020-05-06T11:46:07.641885Z"),
Touched: mustParseTime("2020-05-06T11:46:07.641885Z"),
}
assert.Equal(t, expected, updatedRecord)
}
Expand Down Expand Up @@ -227,6 +230,7 @@ func TestRecordsService_Replace(t *testing.T) {
Records: []string{`"updated"`},
TTL: 300,
Created: mustParseTime("2020-05-06T11:46:07.641885Z"),
Touched: mustParseTime("2020-05-06T11:46:07.641885Z"),
}
assert.Equal(t, expected, updatedRecord)
}
Expand Down Expand Up @@ -271,6 +275,7 @@ func TestRecordsService_GetAll(t *testing.T) {
Records: []string{"10.10.10.10"},
TTL: 60,
Created: mustParseTime("2020-05-06T11:46:07.641885Z"),
Touched: mustParseTime("2020-05-06T11:46:07.641885Z"),
},
{
Name: "example.dedyn.io.",
Expand All @@ -280,6 +285,7 @@ func TestRecordsService_GetAll(t *testing.T) {
Records: []string{"ns1.desec.io.", "ns2.desec.org."},
TTL: 3600,
Created: mustParseTime("2020-05-06T11:46:07.641885Z"),
Touched: mustParseTime("2020-05-06T11:46:07.641885Z"),
},
}
assert.Equal(t, expected, records)
Expand Down Expand Up @@ -333,6 +339,7 @@ func TestRecordsService_BulkCreate(t *testing.T) {
Records: []string{`"txt"`},
TTL: 300,
Created: mustParseTime("2020-05-06T11:46:07.641885Z"),
Touched: mustParseTime("2020-05-06T11:46:07.641885Z"),
}}
assert.Equal(t, expected, newRecords)
}
Expand Down Expand Up @@ -424,6 +431,7 @@ func TestRecordsService_BulkUpdate(t *testing.T) {
Records: []string{`"updated"`},
TTL: 300,
Created: mustParseTime("2020-05-06T11:46:07.641885Z"),
Touched: mustParseTime("2020-05-06T11:46:07.641885Z"),
}}
assert.Equal(t, expected, updatedRecord)
}
Expand Down

0 comments on commit 03b902e

Please sign in to comment.