Skip to content
Snippets Groups Projects
Select Git revision
  • 2b3fd4cf81d27efbced9f433cea7585fb8142054
  • main default protected
  • 1-mage-run-does-not-stop-containers
  • v0.26.0
  • v0.25.0
  • v0.24.0
  • v0.23.0
  • v0.22.0
  • v0.21.0
  • v0.20.0
  • v0.19.0
  • v0.18.0
  • v0.17.0
  • v0.16.0
  • v0.15.0
  • v0.14.0
  • v0.13.0
  • v0.12.0
  • v0.11.0
  • v0.10.0
  • v0.9.0
  • v0.8.0
  • v0.7.0
23 results

database.go

Blame
  • audit_test.go 1.41 KiB
    package audit
    
    import (
    	"encoding/json"
    	"fmt"
    	"gitlab.bob.co.za/bob-public-utils/bobgroup-go-utils/utils"
    	"testing"
    	"time"
    )
    
    type StringType *string
    
    type Tag struct {
    	Name    string
    	Value   *string
    	StrType *StringType
    }
    
    type MockObject struct {
    	Name         *string     `json:"name"`
    	Strings      []*string   `json:"strings"`
    	Tags         []Tag       `json:"tag"`
    	TimeCreated  *time.Time  `json:"time_created"`
    	SingleTagPtr *Tag        `json:"single_tag_ptr"`
    	SingleTag    Tag         `json:"single_tag"`
    	StrType      *StringType `json:"str_type"`
    }
    
    func TestGetChanges(t *testing.T) {
    
    	object1 := MockObject{
    		Strings: []*string{nil},
    	}
    
    	object2 := MockObject{
    		Name:         utils.ValueToPointer("NewName"),
    		Strings:      []*string{utils.ValueToPointer("NewStr1"), utils.ValueToPointer("NewStr2")},
    		Tags:         []Tag{{"NewTag", utils.ValueToPointer("NewValue"), utils.ValueToPointer(StringType(utils.ValueToPointer("NewStrType")))}},
    		TimeCreated:  utils.ValueToPointer(time.Now()),
    		SingleTagPtr: &Tag{"NewSingleTagPtr", utils.ValueToPointer("NewSingleValuePtr"), nil},
    		SingleTag:    Tag{"NewSingleTag", utils.ValueToPointer("NewSingleValue"), nil},
    		StrType:      utils.ValueToPointer(StringType(utils.ValueToPointer("NewStrType"))),
    	}
    
    	changes, err := GetChanges(object1, object2)
    	if err != nil {
    		panic(err)
    	}
    
    	result, _ := json.MarshalIndent(changes, "", "  ")
    	fmt.Println(string(result))
    }