99 "os"
1010 "path/filepath"
1111
12+ "github.com/google/go-cmp/cmp"
1213 ginkgo "github.com/onsi/ginkgo/v2"
1314 "github.com/onsi/gomega"
1415
@@ -21,37 +22,31 @@ var _ = ginkgo.Describe("Agntcy compiler tests", func() {
2122 dockerImage string
2223 mountDest string
2324 mountString string
25+ modelConfigFilePath string
2426 expectedAgentModelFile string
2527 )
2628
2729 ginkgo .BeforeEach (func () {
2830 examplesDir := "../examples/"
29- marketingStrategyPath , err := filepath .Abs (filepath .Join (examplesDir , "dir/e2e/testdata/marketing-strategy " ))
31+ testDataPath , err := filepath .Abs (filepath .Join (examplesDir , "dir/e2e/testdata" ))
3032 gomega .Expect (err ).NotTo (gomega .HaveOccurred ())
3133
3234 tempAgentPath = filepath .Join (os .TempDir (), "agent.json" )
3335 dockerImage = fmt .Sprintf ("%s/dir-ctl:%s" , os .Getenv ("IMAGE_REPO" ), os .Getenv ("DIRECTORY_IMAGE_TAG" ))
34- mountDest = "/opt/marketing-strategy "
35- mountString = fmt .Sprintf ("%s:%s" , marketingStrategyPath , mountDest )
36+ mountDest = "/testdata "
37+ mountString = fmt .Sprintf ("%s:%s" , testDataPath , mountDest )
3638
37- testdataDir , err := filepath .Abs (filepath .Join (examplesDir , "testdata" ))
38- gomega .Expect (err ).NotTo (gomega .HaveOccurred ())
39-
40- expectedAgentModelFile = filepath .Join (testdataDir , "expected_agent.json" )
39+ modelConfigFilePath = filepath .Join (mountDest , "build.config.yaml" )
40+ expectedAgentModelFile = filepath .Join (testDataPath , "agent.json" )
4141 })
4242
4343 ginkgo .Context ("agent compilation" , func () {
4444 ginkgo .It ("should compile an agent" , func () {
4545
4646 dirctlArgs := []string {
4747 "build" ,
48- "--name=marketing-strategy" ,
49- "--version=v1.0.0" ,
50- "--created-at=2025-01-01T00:00:00Z" ,
51- "--artifact-type=python-package" ,
52- "--artifact-url=http://ghcr.io/agntcy/marketing-strategy" ,
53- "--author=author1" ,
54- "--author=author2" ,
48+ "--config" ,
49+ modelConfigFilePath ,
5550 mountDest ,
5651 }
5752
@@ -80,8 +75,20 @@ var _ = ginkgo.Describe("Agntcy compiler tests", func() {
8075 err = json .Unmarshal ([]byte (compiledModelJSON ), & compiled )
8176 gomega .Expect (err ).NotTo (gomega .HaveOccurred ())
8277
83- // Check the compiled agent model without extensions field
84- gomega .Expect (expected ).To (gomega .BeComparableTo (compiled ))
78+ // Filter "created_at" field
79+ filter := cmp .FilterPath (func (p cmp.Path ) bool {
80+ // Ensure the path is deep enough
81+ if len (p ) >= 3 {
82+ if mapStep , ok := p [len (p )- 3 ].(cmp.MapIndex ); ok {
83+ if key , ok := mapStep .Key ().Interface ().(string ); ok && key == "created_at" {
84+ return true // Ignore these paths
85+ }
86+ }
87+ }
88+ return false // Include all other paths
89+ }, cmp .Ignore ())
90+
91+ gomega .Expect (expected ).To (gomega .BeComparableTo (compiled , filter ))
8592 })
8693 })
8794})
0 commit comments