From 82d8072ae3eaa2df34bbd2b3d3a9c73b31c28653 Mon Sep 17 00:00:00 2001 From: Aditya Thebe Date: Thu, 14 Nov 2024 09:10:06 +0545 Subject: [PATCH] feat: add more dependency headers --- migrate/dependency_test.go | 16 ++++++++++------ views/006_config_views.sql | 2 ++ views/021_notification.sql | 2 +- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/migrate/dependency_test.go b/migrate/dependency_test.go index 7fc59e85..d725e39d 100644 --- a/migrate/dependency_test.go +++ b/migrate/dependency_test.go @@ -3,7 +3,7 @@ package migrate import ( "testing" - "github.com/google/go-cmp/cmp" + "github.com/onsi/gomega" ) func TestParseDependencies(t *testing.T) { @@ -25,25 +25,29 @@ func TestParseDependencies(t *testing.T) { }, } + g := gomega.NewWithT(t) // use gomega with std go tests for _, td := range testdata { got, err := parseDependencies(td.script) if err != nil { t.Fatal(err.Error()) } - if diff := cmp.Diff(got, td.want); diff != "" { - t.Fatalf("%s", diff) - } + g.Expect(got).To(gomega.Equal(td.want)) } } func TestDependencyMap(t *testing.T) { + g := gomega.NewWithT(t) // use gomega with std go tests + graph, err := getDependencyTree() if err != nil { t.Fatal(err.Error()) } - if diff := cmp.Diff(graph["functions/drop.sql"], []string{"views/021_notification.sql"}); diff != "" { - t.Fatalf("%v", diff) + expected := map[string][]string{ + "functions/drop.sql": {"views/006_config_views.sql", "views/021_notification.sql"}, + "views/006_config_views.sql": {"views/021_notification.sql"}, } + + g.Expect(graph).To(gomega.BeEquivalentTo(expected)) } diff --git a/views/006_config_views.sql b/views/006_config_views.sql index 4c5af75c..5966c54b 100644 --- a/views/006_config_views.sql +++ b/views/006_config_views.sql @@ -1,3 +1,5 @@ +-- dependsOn: functions/drop.sql + -- Add cascade drops first to make sure all functions and views are always recreated DROP VIEW IF EXISTS configs CASCADE; diff --git a/views/021_notification.sql b/views/021_notification.sql index eb0f151a..979e8466 100644 --- a/views/021_notification.sql +++ b/views/021_notification.sql @@ -1,4 +1,4 @@ --- dependsOn: functions/drop.sql +-- dependsOn: functions/drop.sql, views/006_config_views.sql -- Handle before updates for notifications CREATE OR REPLACE FUNCTION reset_notification_error_before_update ()