test

package
v0.0.0-...-be294a2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 8, 2021 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Dummy_AuthorList = []map[string]interface{}{
	{
		"id":         1,
		"created_at": time.Now(),
		"updated_at": time.Now(),
		"deleted_at": nil,
		"email":      "abc@abc.com",
		"kid":        "",
		"first_name": "abc",
		"last_name":  "cba",
		"birth_date": time.Now(),
		"gender":     "male",
		"permission": map[string]interface{}{
			"id":              1,
			"created_at":      time.Now(),
			"updated_at":      time.Now(),
			"deleted_at":      nil,
			"user_id":         1,
			"user":            nil,
			"organisation_id": 1,
			"organisation":    nil,
			"role":            "owner",
		},
	},
	{
		"id":         2,
		"created_at": time.Now(),
		"updated_at": time.Now(),
		"deleted_at": nil,
		"email":      "def@def.com",
		"kid":        "",
		"first_name": "def",
		"last_name":  "fed",
		"birth_date": time.Now(),
		"gender":     "male",
		"permission": map[string]interface{}{
			"id":              2,
			"created_at":      time.Now(),
			"updated_at":      time.Now(),
			"deleted_at":      nil,
			"user_id":         2,
			"user":            nil,
			"organisation_id": 1,
			"organisation":    nil,
			"role":            "member",
		},
	},
}

Dummy response for the mock server requesting list of authors Endpoint this is sent for is /organisations/[id]/users

View Source
var Dummy_KetoPolicy = []map[string]interface{}{
	{
		"id":          "id:org:1:app:dega:space:1:test-policy-4",
		"description": "",
		"subjects": []string{
			"1",
			"2",
		},
		"resources": []string{
			"resources:org:1:app:dega:space:1:categories",
			"resources:org:1:app:dega:space:1:tags",
		},
		"actions": []string{
			"actions:org:1:app:dega:space:1:categories:get",
			"actions:org:1:app:dega:space:1:categories:create",
			"actions:org:1:app:dega:space:1:tags:update",
			"actions:org:1:app:dega:space:1:tags:delete",
		},
		"effect":     "allow",
		"conditions": nil,
	},
	{
		"id":          "id:org:1:app:dega:space:1:test-policy-0",
		"description": "",
		"subjects": []string{
			"1",
		},
		"resources": []string{
			"resources:org:12:app:dega:space:18:policies",
		},
		"actions": []string{
			"actions:org:12:app:dega:space:18:policies:get",
			"actions:org:12:app:dega:space:18:policies:create",
			"actions:org:12:app:dega:space:18:policies:update",
			"actions:org:12:app:dega:space:18:policies:delete",
		},
		"effect":     "allow",
		"conditions": nil,
	},
}
View Source
var Dummy_Org = map[string]interface{}{
	"id":         1,
	"created_at": time.Now(),
	"updated_at": time.Now(),
	"deleted_at": nil,
	"title":      "test org",
	"slug":       "test-org",
	"permission": map[string]interface{}{
		"id":              1,
		"created_at":      time.Now(),
		"updated_at":      time.Now(),
		"deleted_at":      nil,
		"user_id":         1,
		"user":            nil,
		"organisation_id": 1,
		"organisation":    nil,
		"role":            "owner",
	},
}

Dummy response body for the mock server requesting organisation data Endpoint this is sent for is /organisations

View Source
var Dummy_OrgList = []map[string]interface{}{
	Dummy_Org,
}
View Source
var Dummy_Org_Member_List = []map[string]interface{}{
	map[string]interface{}{
		"id":         1,
		"created_at": time.Now(),
		"updated_at": time.Now(),
		"deleted_at": nil,
		"title":      "test org",
		"permission": map[string]interface{}{
			"id":              1,
			"created_at":      time.Now(),
			"updated_at":      time.Now(),
			"deleted_at":      nil,
			"user_id":         1,
			"user":            nil,
			"organisation_id": 1,
			"organisation":    nil,
			"role":            "member",
		},
	},
}
View Source
var Dummy_Role = map[string]interface{}{
	"id": "roles:org:1:admin",
	"members": []string{
		"1",
	},
}
View Source
var Dummy_SingleMock = map[string]interface{}{
	"id":          "id:org:1:app:dega:space:1:test-policy-0",
	"description": "",
	"subjects": []string{
		"1",
	},
	"resources": []string{
		"resources:org:12:app:dega:space:18:policies",
	},
	"actions": []string{
		"actions:org:12:app:dega:space:18:policies:get",
		"actions:org:12:app:dega:space:18:policies:create",
		"actions:org:12:app:dega:space:18:policies:update",
		"actions:org:12:app:dega:space:18:policies:delete",
	},
	"effect":     "allow",
	"conditions": nil,
}

Dummy single policy

View Source
var EmptyMeili = map[string]interface{}{
	"hits":             []map[string]interface{}{},
	"offset":           0,
	"limit":            20,
	"nbHits":           0,
	"exhaustiveNbHits": false,
	"processingTimeMs": 2,
	"query":            "test",
}
View Source
var GoogleResponse = map[string]interface{}{
	"claims": []map[string]interface{}{
		map[string]interface{}{
			"text":      "Shopkeepers sleeping inside shops due to Modi govt's handling of COVID-19",
			"claimant":  "Social media",
			"claimDate": "2016-06-20T00:00:00Z",
			"claimReview": []map[string]interface{}{
				map[string]interface{}{
					"publisher": map[string]interface{}{
						"name": "Alt News",
						"site": "altnews.in",
					},
					"url":           "https://www.altnews.in/congress-rohan-gupta-shares-old-images-of-shopkeeper-falling-a-sleep-to-target-pm-modi/",
					"title":         "Photos of shopkeepers sleeping inside shops from 2019 shared as recent",
					"reviewDate":    "2020-09-28T00:00:00Z",
					"textualRating": "False",
					"languageCode":  "en",
				},
			},
		},
	},
	"nextPageToken": "CBQ",
}
View Source
var IFramelyResponse = map[string]interface{}{
	"meta": map[string]interface{}{
		"description": "GitHub is where over 50 million developers shape the future of software, together. Contribute to the open source community, manage your Git repositories, review code like a pro, track bugs and feat...",
		"title":       "GitHub: Where the world builds software",
		"theme-color": "#1e2327",
		"canonical":   "https://github.com/",
		"site":        "GitHub",
	},
	"links": map[string]interface{}{
		"thumbnail": []interface{}{
			map[string]interface{}{
				"href": "https://github.githubassets.com/images/modules/open_graph/github-mark.png",
				"type": "image/png",
				"rel": []interface{}{
					"twitter",
					"thumbnail",
					"ssl",
					"og",
				},
				"media": map[string]interface{}{
					"width":  1200,
					"height": 620,
				},
			},
		},
		"icon": []interface{}{
			map[string]interface{}{
				"href": "https://github.githubassets.com/favicons/favicon.svg",
				"type": "image/svg+xml",
			},
		},
	},
}
View Source
var MeiliHits = map[string]interface{}{
	"hits": []map[string]interface{}{
		{
			"object_id":   "post_3",
			"kind":        "post",
			"description": "This is a test post with claim",
			"id":          1,
			"slug":        "test-post-2",
			"space_id":    1,
			"title":       "Test Post",
			"category_ids": []uint{
				2,
			},
			"excerpt":        "Test post with claim",
			"is_featured":    true,
			"is_highlighted": true,
			"is_sticky":      true,
			"published_date": -62135596800,
			"status":         "draft",
			"subtitle":       "Test Post",
			"tag_ids": []uint{
				42,
			},
			"claim_ids": []uint{
				5,
			},
			"format_id": 3,
		},
		{
			"object_id":       "claim_2",
			"kind":            "claim",
			"description":     "This is a test claim",
			"id":              2,
			"slug":            "test-claim",
			"space_id":        1,
			"title":           "Test Claim",
			"checked_date":    1598959138,
			"claim_date":      -62135596800,
			"claim_sources":   "secret sources",
			"claimant_id":     2,
			"rating_id":       2,
			"review":          "Bad review",
			"review_sources":  "Good sources",
			"review_tag_line": "Bad review good sources",
		},
	},
	"offset":           0,
	"limit":            20,
	"nbHits":           7,
	"exhaustiveNbHits": false,
	"processingTimeMs": 2,
	"query":            "test",
}
View Source
var OembedResponse = map[string]interface{}{
	"type":             "link",
	"version":          "1.0",
	"title":            "GitHub: Where the world builds software",
	"url":              "https://github.com/",
	"provider_name":    "GitHub",
	"description":      "GitHub is where over 50 million developers shape the future of software, together. Contribute to the open source community, manage your Git repositories, review code like a pro, track bugs and feat...",
	"thumbnail_url":    "https://github.githubassets.com/images/modules/open_graph/github-mark.png",
	"thumbnail_width":  1200,
	"thumbnail_height": 620,
}
View Source
var PaiganatedOrg = map[string]interface{}{
	"nodes": []interface{}{
		Dummy_Org,
	},
	"total": 1,
}
View Source
var ReturnUpdate = map[string]interface{}{
	"updateId": 1,
}

Functions

func CheckSpaceMock

func CheckSpaceMock(mock sqlmock.Sqlmock)

func DisableKavachGock

func DisableKavachGock(serverURL string)

func DisableKetoGock

func DisableKetoGock(serverURL string)

func DisableMeiliGock

func DisableMeiliGock(serverURL string)

func ExpectationsMet

func ExpectationsMet(t *testing.T, mock sqlmock.Sqlmock)

ExpectationsMet checks if all the expectations are fulfilled

func GoogleFactCheckGock

func GoogleFactCheckGock()

func IFramelyGock

func IFramelyGock()

func KavachGock

func KavachGock()

func KetoGock

func KetoGock()

func MeiliGock

func MeiliGock()

func MockServer

func MockServer()

MockServer is created to intercept HTTP Calls outside this project. Mocking the external project servers helps with Unit Testing.

func NilJsonb

func NilJsonb() postgres.Jsonb

NilJsonb return nil json

func RunDefaultNATSServer

func RunDefaultNATSServer() *server.Server

RunDefaultNATSServer will run a nats server on the default port.

func RunServerOnPort

func RunServerOnPort(port int) *server.Server

RunServerOnPort will run a server on the given port.

func RunServerWithConfig

func RunServerWithConfig(configFile string) (*server.Server, *server.Options)

RunServerWithConfig will run a server with the given configuration file.

func RunServerWithOptions

func RunServerWithOptions(opts server.Options) *server.Server

RunServerWithOptions will run a server with the given options.

func SetupMockDB

func SetupMockDB() sqlmock.Sqlmock

SetupMockDB setups the mock sql db

Types

type AnyTime

type AnyTime struct{}

AnyTime To match time for test sqlmock queries

func (AnyTime) Match

func (a AnyTime) Match(v driver.Value) bool

Match satisfies sqlmock.Argument interface

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL