Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 25 additions & 18 deletions external/resources/resources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ accounts:
docs: "https://documentation.elasticpath.com/commerce-cloud/docs/api/customers-and-accounts/account-management/accounts/get-all-accounts.html"
url: "/v2/accounts"
get-entity:
docs: "https://documentation.elasticpath.com/commerce-cloud/docs/api/customers-and-accounts/account-management/accounts/get-an-account.html"
#TODO this link is wrong, but the actual page doesn't exist.
docs: "https://documentation.elasticpath.com/commerce-cloud/docs/api/customers-and-accounts/account-management/accounts/index.html"
url: "/v2/accounts/{accounts}"
update-entity:
docs: "https://documentation.elasticpath.com/commerce-cloud/docs/api/customers-and-accounts/account-management/accounts/update-an-account.html"
Expand Down Expand Up @@ -273,47 +274,53 @@ flows:
type: STRING
integration-jobs:
singular-name: "integration-job"
json-api-type: "integration-log"
json-api-type: "integration-job"
json-api-format: "legacy"
docs: "????/https://documentation.elasticpath.com/commerce-cloud/docs/api/advanced/events/get-event-logs.html#get-get-jobs-for-an-event"
docs: "https://documentation.elasticpath.com/commerce-cloud/docs/api/advanced/integrations/get-integration-logs.html#get-get-jobs-for-an-integration"
get-collection:
docs: "????/https://documentation.elasticpath.com/commerce-cloud/docs/api/advanced/events/get-event-logs.html#get-get-jobs-for-an-event"
docs: "https://documentation.elasticpath.com/commerce-cloud/docs/api/advanced/integrations/get-integration-logs.html#get-get-jobs-for-an-integration"
url: "/v2/integrations/{integrations}/jobs"
get-entity:
docs: "????/https://documentation.elasticpath.com/commerce-cloud/docs/api/advanced/events/get-event-logs.html#get-get-jobs-for-an-event"
attributes:
integration-job-log:
singular-name: "integration-job-log"
json-api-type: "integration-job"
json-api-format: "legacy"
docs: "https://documentation.elasticpath.com/commerce-cloud/docs/api/advanced/integrations/get-integration-logs.html#get-get-all-logs-for-a-job"
get-collection:
docs: "https://documentation.elasticpath.com/commerce-cloud/docs/api/advanced/integrations/get-integration-logs.html#get-get-all-logs-for-a-job"
url: "/v2/integrations/{integrations}/jobs/{integration_jobs}/logs"
attributes:
integration-logs:
singular-name: "integration-log"
json-api-type: "integration-log"
json-api-format: "legacy"
docs: "????/https://documentation.elasticpath.com/commerce-cloud/docs/api/advanced/events/get-event-logs.html"
docs: "https://documentation.elasticpath.com/commerce-cloud/docs/api/advanced/integrations/get-integration-logs.html"
get-collection:
docs: "????/https://documentation.elasticpath.com/commerce-cloud/docs/api/advanced/events/get-event-logs.html"
docs: "https://documentation.elasticpath.com/commerce-cloud/docs/api/advanced/integrations/get-integration-logs.html#get-get-all-logs"
url: "/v2/integrations/logs"
get-entity:
docs: "????/https://documentation.elasticpath.com/commerce-cloud/docs/api/advanced/events/get-event-logs.html"
url: "/v2/integrations/logs"
docs: "https://documentation.elasticpath.com/commerce-cloud/docs/api/advanced/integrations/get-integration-logs.html#get-get-logs-for-an-integration"
url: "/v2/integrations/{integrations}/logs"
attributes:
integrations:
singular-name: "integration"
json-api-type: "integration"
json-api-format: "legacy"
docs: "????/https://documentation.elasticpath.com/commerce-cloud/docs/api/advanced/events/create-an-event.html"
docs: "https://documentation.elasticpath.com/commerce-cloud/docs/api/advanced/integrations/index.html"
get-collection:
docs: "https://documentation.elasticpath.com/commerce-cloud/docs/api/advanced/events/create-an-event.html"
docs: "https://documentation.elasticpath.com/commerce-cloud/docs/api/advanced/integrations/get-all-integrations.html"
url: "/v2/integrations"
get-entity:
docs: "????/https://documentation.elasticpath.com/commerce-cloud/docs/api/advanced/events/create-an-event.html"
docs: "https://documentation.elasticpath.com/commerce-cloud/docs/api/advanced/integrations/get-an-integration.html"
url: "/v2/integrations/{integrations}"
update-entity:
docs: "????/https://documentation.elasticpath.com/commerce-cloud/docs/api/advanced/events/create-an-event.html"
docs: "https://documentation.elasticpath.com/commerce-cloud/docs/api/advanced/integrations/update-an-integration.html"
url: "/v2/integrations/{integrations}"
delete-entity:
docs: "????/https://documentation.elasticpath.com/commerce-cloud/docs/api/advanced/events/create-an-event.html"
docs: "https://documentation.elasticpath.com/commerce-cloud/docs/api/advanced/integrations/delete-an-integration.html"
url: "/v2/integrations/{integrations}"
create-entity:
docs: "????/https://documentation.elasticpath.com/commerce-cloud/docs/api/advanced/events/create-an-event.html"
docs: "https://documentation.elasticpath.com/commerce-cloud/docs/api/advanced/integrations/create-an-integration.html"
url: "/v2/integrations"
content-type: application/json
attributes:
Expand Down Expand Up @@ -533,7 +540,7 @@ pcm-products:
docs: "https://documentation.elasticpath.com/commerce-cloud/docs/api/pcm/products/delete-a-product.html"
url: "/pcm/products/{pcm_products}"
create-entity:
docs: "https://documentation.elasticpath.com/commerce-cloud/docs/api/pcm/products/create-a-product.htmll"
docs: "https://documentation.elasticpath.com/commerce-cloud/docs/api/pcm/products/create-a-product.html"
url: "/pcm/products"
content-type: application/json
attributes:
Expand Down Expand Up @@ -665,7 +672,7 @@ user-authentication-infos:
docs: "https://documentation.elasticpath.com/commerce-cloud/docs/api/single-sign-on/user-authentication-info/get-all-user-authentication-info.html"
url: "/v2/authentication-realms/{authentication_realms}/user-authentication-info"
get-entity:
docs: "https://documentation.elasticpath.com/commerce-cloud/docs/api/single-sign-on/user-authentication-info/get-a-user-authentication-info.htmll"
docs: "https://documentation.elasticpath.com/commerce-cloud/docs/api/single-sign-on/user-authentication-info/get-a-user-authentication-info.html"
url: "/v2/authentication-realms/{authentication_realms}/user-authentication-info/{user_authentication_infos}"
update-entity:
docs: "https://documentation.elasticpath.com/commerce-cloud/docs/api/single-sign-on/user-authentication-info/update-a-user-authentication-info.html"
Expand Down
60 changes: 30 additions & 30 deletions external/resources/resources_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ func TestUriTemplatesAllReferenceValidResource(t *testing.T) {

if err != nil {
errors += fmt.Sprintf("Could not process CREATE uri for resource %s, error:%s\n", key, err)
}

for _, variable := range template.Varnames() {
resourceName := strings.ReplaceAll(variable, "_", "-")
if _, ok := resources[resourceName]; !ok {
errors += fmt.Sprintf("Error processing CREATE uri for resource %s, the URI template references a resource %s, but could not find it", key, resourceName)
} else {
for _, variable := range template.Varnames() {
resourceName := strings.ReplaceAll(variable, "_", "-")
if _, ok := resources[resourceName]; !ok {
errors += fmt.Sprintf("Error processing CREATE uri for resource %s, the URI template references a resource %s, but could not find it\n", key, resourceName)
}
}
}
}
Expand All @@ -36,12 +36,12 @@ func TestUriTemplatesAllReferenceValidResource(t *testing.T) {

if err != nil {
errors += fmt.Sprintf("Could not process UPDATE uri for resource %s, error:%s\n", key, err)
}

for _, variable := range template.Varnames() {
resourceName := strings.ReplaceAll(variable, "_", "-")
if _, ok := resources[resourceName]; !ok {
errors += fmt.Sprintf("Error processing UPDATE uri for resource %s, the URI template references a resource %s, but could not find it", key, resourceName)
} else {
for _, variable := range template.Varnames() {
resourceName := strings.ReplaceAll(variable, "_", "-")
if _, ok := resources[resourceName]; !ok {
errors += fmt.Sprintf("Error processing UPDATE uri for resource %s, the URI template references a resource %s, but could not find it\n", key, resourceName)
}
}
}
}
Expand All @@ -51,12 +51,12 @@ func TestUriTemplatesAllReferenceValidResource(t *testing.T) {

if err != nil {
errors += fmt.Sprintf("Could not process DELETE uri for resource %s, error:%s\n", key, err)
}

for _, variable := range template.Varnames() {
resourceName := strings.ReplaceAll(variable, "_", "-")
if _, ok := resources[resourceName]; !ok {
errors += fmt.Sprintf("Error processing DELETE uri for resource %s, the URI template references a resource %s, but could not find it", key, resourceName)
} else {
for _, variable := range template.Varnames() {
resourceName := strings.ReplaceAll(variable, "_", "-")
if _, ok := resources[resourceName]; !ok {
errors += fmt.Sprintf("Error processing DELETE uri for resource %s, the URI template references a resource %s, but could not find it\n", key, resourceName)
}
}
}
}
Expand All @@ -66,12 +66,12 @@ func TestUriTemplatesAllReferenceValidResource(t *testing.T) {

if err != nil {
errors += fmt.Sprintf("Could not process GET entity uri for resource %s, error:%s\n", key, err)
}

for _, variable := range template.Varnames() {
resourceName := strings.ReplaceAll(variable, "_", "-")
if _, ok := resources[resourceName]; !ok {
errors += fmt.Sprintf("Error processing GET entity uri for resource %s, the URI template references a resource %s, but could not find it", key, resourceName)
} else {
for _, variable := range template.Varnames() {
resourceName := strings.ReplaceAll(variable, "_", "-")
if _, ok := resources[resourceName]; !ok {
errors += fmt.Sprintf("Error processing GET entity uri for resource %s, the URI template references a resource %s, but could not find it\n", key, resourceName)
}
}
}
}
Expand All @@ -81,12 +81,12 @@ func TestUriTemplatesAllReferenceValidResource(t *testing.T) {

if err != nil {
errors += fmt.Sprintf("Could not process GET collection uri for resource %s, error:%s\n", key, err)
}

for _, variable := range template.Varnames() {
resourceName := strings.ReplaceAll(variable, "_", "-")
if _, ok := resources[resourceName]; !ok {
errors += fmt.Sprintf("Error processing GET collection uri for resource %s, the URI template references a resource %s, but could not find it", key, resourceName)
} else {
for _, variable := range template.Varnames() {
resourceName := strings.ReplaceAll(variable, "_", "-")
if _, ok := resources[resourceName]; !ok {
errors += fmt.Sprintf("Error processing GET collection uri for resource %s, the URI template references a resource %s, but could not find it\n", key, resourceName)
}
}
}
}
Expand Down
47 changes: 47 additions & 0 deletions external/resources/resources_yaml_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package resources

import (
"net/http"
"testing"
)

func TestResourceDocsExist(t *testing.T) {
const httpStatusCodeOk = 200

Resources := GetPluralResources()
linksReferenceCount := make(map[string]int, len(Resources))

for resource := range Resources {
linksReferenceCount[Resources[resource].Docs]++
if Resources[resource].GetCollectionInfo != nil {
linksReferenceCount[Resources[resource].GetCollectionInfo.Docs]++
}
if Resources[resource].CreateEntityInfo != nil {
linksReferenceCount[Resources[resource].CreateEntityInfo.Docs]++
}
if Resources[resource].GetEntityInfo != nil {
linksReferenceCount[Resources[resource].GetEntityInfo.Docs]++
}
if Resources[resource].UpdateEntityInfo != nil {
linksReferenceCount[Resources[resource].UpdateEntityInfo.Docs]++
}
if Resources[resource].DeleteEntityInfo != nil {
linksReferenceCount[Resources[resource].DeleteEntityInfo.Docs]++
}
}

for link := range linksReferenceCount {
response, err := http.DefaultClient.Head(link)
if err != nil {
t.Errorf("Error Retrieving Link\nLink: %s\nError Message: %s\nReference Count: %d", link, err, linksReferenceCount[link])
} else {
if response.StatusCode != httpStatusCodeOk {
t.Errorf("Unexpected Response\nLink: %s\nExpected Status Code: %d\nActual Status Code: %d\nReference Count: %d",
link, httpStatusCodeOk, response.StatusCode, linksReferenceCount[link])
}
if err := response.Body.Close(); err != nil {
t.Errorf("Error Closing Reponse Body\nError Message: %s", err)
}
}
}
}