-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from atlanhq/integration-tests
DVX:183 - Add Integration Tests and Github Actions
- Loading branch information
Showing
16 changed files
with
454 additions
and
142 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,31 @@ | ||
name: Go Tests | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
env: | ||
ATLAN_API_KEY: ${{ secrets.ATLAN_API_KEY }} | ||
ATLAN_BASE_URL: ${{ secrets.ATLAN_BASE_URL }} | ||
|
||
jobs: | ||
build: | ||
name: Run Go Tests | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: '1.22.2' | ||
|
||
- name: Check out code into the Go module directory | ||
uses: actions/checkout@v3 | ||
|
||
- name: Install gotestsum | ||
run: go install gotest.tools/gotestsum@latest | ||
|
||
- name: Run tests | ||
run: gotestsum --format testdox -- -v ./... |
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
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,74 @@ | ||
package client | ||
|
||
import ( | ||
"fmt" | ||
"github.com/stretchr/testify/assert" | ||
"testing" | ||
) | ||
|
||
func TestIntegrationAtlanTagCache_RefreshCache(t *testing.T) { | ||
if testing.Short() { | ||
t.Skip("skipping integration test") | ||
} | ||
LoggingEnabled = false | ||
client := NewContext() | ||
cache := NewAtlanTagCache(client) | ||
|
||
// Execute | ||
err := cache.RefreshCache() | ||
|
||
// Verify | ||
assert.NoError(t, err) | ||
// Check that cache is not empty, indicating data was fetched | ||
assert.NotEmpty(t, cache.cacheByID) | ||
} | ||
|
||
func TestIntegrationAtlanTagCache_GetIDForName(t *testing.T) { | ||
if testing.Short() { | ||
t.Skip("skipping integration test") | ||
} | ||
LoggingEnabled = false | ||
|
||
client := NewContext() | ||
cache := NewAtlanTagCache(client) | ||
|
||
// Ensure the cache is populated | ||
resp, _ := GetAll() | ||
tagName := resp.AtlanTagDefs[0].DisplayName | ||
|
||
//_ = cache.RefreshCache() | ||
|
||
fmt.Println("Tag Name: ", tagName) | ||
id, err := cache.GetIDForName(tagName) | ||
|
||
// Verify | ||
assert.NoError(t, err) | ||
assert.NotEmpty(t, id) // ID should be non-empty if the tag exists | ||
|
||
// Test not found scenario | ||
_, err = cache.GetIDForName("NonExistentTag") | ||
assert.Nil(t, nil) // Expect error(nil) since tag does not exist | ||
} | ||
|
||
func TestIntegrationAtlanTagCache_GetNameForID(t *testing.T) { | ||
if testing.Short() { | ||
t.Skip("skipping integration test") | ||
} | ||
LoggingEnabled = false | ||
client := NewContext() | ||
cache := NewAtlanTagCache(client) | ||
|
||
// Ensure the cache is populated | ||
_ = cache.RefreshCache() | ||
|
||
// Assuming "BBDjIBZUNHtKPExR1Z3a5I" is a valid GUID | ||
name, err := cache.GetNameForID("BBDjIBZUNHtKPExR1Z3a5I") | ||
|
||
// Verify | ||
assert.NoError(t, err) | ||
assert.NotEmpty(t, name) // Name should be non-empty if the ID is valid | ||
|
||
// Test not found scenario | ||
_, err = cache.GetNameForID("123456") | ||
assert.Nil(t, nil) // Expect error(nil) since ID does not exist | ||
} |
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
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
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,59 @@ | ||
package client | ||
|
||
import ( | ||
"fmt" | ||
"github.com/atlanhq/atlan-go/atlan" | ||
"github.com/stretchr/testify/assert" | ||
"testing" | ||
"time" | ||
) | ||
|
||
func TestIntegrationFluentSearch(t *testing.T) { | ||
if testing.Short() { | ||
t.Skip("skipping integration test") | ||
} | ||
LoggingEnabled = false | ||
ctx := NewContext() | ||
|
||
// Create a glossary | ||
g := &AtlasGlossary{} | ||
g.Creator(GlossaryName, atlan.AtlanIconAirplaneInFlight) | ||
response, err := Save(g) | ||
if err != nil { | ||
t.Errorf("Error: %v", err) | ||
} | ||
assert.NotNil(t, response, "fetched glossary should not be nil") | ||
|
||
time.Sleep(5 * time.Second) | ||
// Search for glossary with Active Status and Name as GlossaryName | ||
searchResult, err := NewFluentSearch(). | ||
PageSizes(10). | ||
ActiveAssets(). | ||
Where(ctx.Glossary.NAME.Eq(GlossaryName)). | ||
//IncludeOnResults("guid"). | ||
Execute() | ||
|
||
if err != nil { | ||
fmt.Printf("Error executing search: %v\n", err) | ||
return | ||
} | ||
|
||
assert.NotNil(t, searchResult, "search result should not be nil") | ||
assert.Equal(t, 1, len(searchResult), "number of glossaries should be 1") | ||
assert.Equal(t, GlossaryName, *searchResult[0].Entities[0].DisplayName, "glossary name should match") | ||
|
||
// Search for glossaries starts with letter G and sort them in ascending order by name | ||
searchResult, err = NewFluentSearch(). | ||
PageSizes(10). | ||
ActiveAssets(). | ||
Where(ctx.Glossary.NAME.StartsWith("gsdk", nil)). | ||
Sort(NAME, atlan.SortOrderAscending). | ||
Execute() | ||
|
||
assert.Equal(t, 1, len(searchResult), "number of glossaries should be 1") | ||
assert.Equal(t, "g", string((*searchResult[0].Entities[0].DisplayName)[0]), "glossary name should start with G") | ||
|
||
// Delete already created glossary | ||
deleteresponse, _ := PurgeByGuid([]string{response.MutatedEntities.CREATE[0].Guid}) | ||
assert.NotNil(t, deleteresponse, "fetched glossary should not be nil") | ||
} |
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
Oops, something went wrong.