Skip to content

Commit

Permalink
Merge pull request #40 from atlanhq/DVX-525
Browse files Browse the repository at this point in the history
DVX-525: Fixed missing "description" in the `SearchAttributes` struct
  • Loading branch information
Aryamanz29 authored Jun 19, 2024
2 parents f54645b + badda1f commit 68a4383
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
17 changes: 14 additions & 3 deletions atlan/assets/fluent_search_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@ package assets

import (
"fmt"
"github.com/atlanhq/atlan-go/atlan"
"github.com/stretchr/testify/assert"
"testing"
"time"

"github.com/atlanhq/atlan-go/atlan"
"github.com/atlanhq/atlan-go/atlan/model/structs"
"github.com/stretchr/testify/assert"
)

const GlossaryDescription = "Automated testing of GO SDK."

func TestIntegrationFluentSearch(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test")
Expand All @@ -17,6 +21,7 @@ func TestIntegrationFluentSearch(t *testing.T) {
// Create a glossary
g := &AtlasGlossary{}
g.Creator(GlossaryName, atlan.AtlanIconAirplaneInFlight)
g.Description = structs.StringPtr(GlossaryDescription)
response, err := Save(g)
if err != nil {
t.Errorf("Error: %v", err)
Expand All @@ -29,7 +34,7 @@ func TestIntegrationFluentSearch(t *testing.T) {
PageSizes(10).
ActiveAssets().
Where(ctx.Glossary.NAME.Eq(GlossaryName)).
//IncludeOnResults("guid").
IncludeOnResults("description").
Execute()

if err != nil {
Expand All @@ -40,6 +45,7 @@ func TestIntegrationFluentSearch(t *testing.T) {
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")
assert.Equal(t, GlossaryDescription, *searchResult[0].Entities[0].Description, "glossary description should exist")

// Search for glossaries starts with letter G and sort them in ascending order by name
searchResult, err = NewFluentSearch().
Expand All @@ -49,6 +55,11 @@ func TestIntegrationFluentSearch(t *testing.T) {
Sort(NAME, atlan.SortOrderAscending).
Execute()

if err != nil {
fmt.Printf("Error executing search: %v\n", err)
return
}

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")

Expand Down
6 changes: 5 additions & 1 deletion atlan/assets/glossary_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package assets
import (
"encoding/json"
"errors"
"time"

"github.com/atlanhq/atlan-go/atlan"
"github.com/atlanhq/atlan-go/atlan/model/structs"
"time"
)

const (
Expand Down Expand Up @@ -126,6 +127,9 @@ func (g *AtlasGlossary) MarshalJSON() ([]byte, error) {
if g.DisplayName != nil && *g.DisplayName != "" {
customJSON["attributes"].(map[string]interface{})["displayName"] = *g.DisplayName
}
if g.Description != nil && *g.Description != "" {
customJSON["attributes"].(map[string]interface{})["description"] = *g.Description
}

// Marshal the custom JSON
return json.MarshalIndent(customJSON, "", " ")
Expand Down
3 changes: 3 additions & 0 deletions atlan/model/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package model

import (
"encoding/json"

"github.com/atlanhq/atlan-go/atlan"
"github.com/atlanhq/atlan-go/atlan/model/structs"
)
Expand Down Expand Up @@ -485,6 +486,7 @@ type SearchAttributes struct {
QualifiedName *string `json:"qualifiedName,omitempty"`
Name *string `json:"name,omitempty"`
UserDescription *string `json:"userDescription,omitempty"`
Description *string `json:"description,omitempty"`
DataType *string `json:"dataType,omitempty"`
IsPrimary *bool `json:"isPrimary,omitempty"`
IsNullable *bool `json:"isNullable,omitempty"`
Expand Down Expand Up @@ -534,6 +536,7 @@ func (sa *SearchAssets) UnmarshalJSON(data []byte) error {
sa.Name = aux.SearchAttributes.Name
sa.QualifiedName = aux.SearchAttributes.QualifiedName
sa.DataType = aux.SearchAttributes.DataType
sa.Description = aux.SearchAttributes.Description
sa.UserDescription = aux.SearchAttributes.UserDescription
sa.IsPrimary = aux.SearchAttributes.IsPrimary
sa.IsNullable = aux.SearchAttributes.IsNullable
Expand Down

0 comments on commit 68a4383

Please sign in to comment.