-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add a very simple test case (with anonymized data)
- Loading branch information
1 parent
7a373ff
commit 67d4ea7
Showing
2 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
--- | ||
version: 1 | ||
interactions: | ||
- request: | ||
body: | | ||
{"query":"query($auditLogCursor:String$auditLogOrder:AuditLogOrder$login:String!$perPage:Int!){organization(login: $login){login,auditLog(first: $perPage, after: $auditLogCursor, orderBy: $auditLogOrder){totalCount,nodes{__typename,... on Node{id},... on AuditEntry{action,actor{__typename},actorLogin,actorIp,createdAt,operationType,userLogin}},pageInfo{endCursor,hasNextPage}}}}","variables":{"auditLogCursor":null,"auditLogOrder":null,"login":"mergestat","perPage":50}} | ||
form: {} | ||
headers: | ||
Content-Type: | ||
- application/json | ||
url: https://api.github.com/graphql | ||
method: POST | ||
response: | ||
body: '{"data":{"organization":{"login":"mergestat","auditLog":{"totalCount":39,"nodes":[{"__typename":"RepoCreateAuditEntry","id":"fake-id","action":"repo.create","actor":{"__typename":"User"},"actorLogin":"patrickdevivo","actorIp":"0.0.0.0","createdAt":"2022-06-29T14:06:02.543Z","operationType":"CREATE","userLogin":null}],"pageInfo":{"endCursor":null,"hasNextPage":false}}}}}' | ||
headers: | ||
Access-Control-Allow-Origin: | ||
- '*' | ||
Access-Control-Expose-Headers: | ||
- ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, | ||
X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, | ||
X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, | ||
X-GitHub-Request-Id, Deprecation, Sunset | ||
Content-Security-Policy: | ||
- default-src 'none' | ||
Content-Type: | ||
- application/json; charset=utf-8 | ||
Date: | ||
- Wed, 29 Jun 2022 15:22:01 GMT | ||
Referrer-Policy: | ||
- origin-when-cross-origin, strict-origin-when-cross-origin | ||
Server: | ||
- GitHub.com | ||
Strict-Transport-Security: | ||
- max-age=31536000; includeSubdomains; preload | ||
Vary: | ||
- Accept-Encoding, Accept, X-Requested-With | ||
X-Accepted-Oauth-Scopes: | ||
- repo | ||
X-Content-Type-Options: | ||
- nosniff | ||
X-Frame-Options: | ||
- deny | ||
X-Github-Media-Type: | ||
- github.v4; format=json | ||
X-Github-Request-Id: | ||
- D50C:5249:26D5CB9:574FAA0:62BC6E18 | ||
X-Oauth-Scopes: | ||
- admin:enterprise, admin:org, project, repo, user | ||
X-Ratelimit-Limit: | ||
- "5000" | ||
X-Ratelimit-Remaining: | ||
- "4970" | ||
X-Ratelimit-Reset: | ||
- "1656516380" | ||
X-Ratelimit-Resource: | ||
- graphql | ||
X-Ratelimit-Used: | ||
- "30" | ||
X-Xss-Protection: | ||
- "0" | ||
status: 200 OK | ||
code: 200 | ||
duration: 1.438554716s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package github_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/mergestat/mergestat/extensions/internal/tools" | ||
) | ||
|
||
func TestOrgAuditLog(t *testing.T) { | ||
cleanup := newRecorder(t) | ||
defer cleanup() | ||
|
||
db := Connect(t, Memory) | ||
|
||
rows, err := db.Query("SELECT * FROM github_org_audit_log('mergestat') LIMIT 1") | ||
if err != nil { | ||
t.Fatalf("failed to execute query: %v", err.Error()) | ||
} | ||
defer rows.Close() | ||
|
||
colCount, _, err := tools.RowContent(rows) | ||
if err != nil { | ||
t.Fatalf("failed to retrieve row contents: %v", err.Error()) | ||
} | ||
|
||
if expected := 9; colCount != expected { | ||
t.Fatalf("expected %d columns, got: %d", expected, colCount) | ||
} | ||
} |