@@ -658,38 +658,96 @@ func TestApps_Interfaces(t *testing.T) {
658
658
})
659
659
660
660
t .Run ("AppBuildableComponentSpec" , func (t * testing.T ) {
661
- for _ , impl := range []interface {}{
662
- & AppServiceSpec {},
663
- & AppWorkerSpec {},
664
- & AppJobSpec {},
665
- & AppStaticSiteSpec {},
661
+ for impl , wantMatch := range map [any ]bool {
662
+ & AppServiceSpec {}: true ,
663
+ & AppWorkerSpec {}: true ,
664
+ & AppJobSpec {}: true ,
665
+ & AppStaticSiteSpec {}: true ,
666
+ & AppFunctionsSpec {}: true ,
667
+
668
+ & AppDatabaseSpec {}: false ,
669
+ } {
670
+ _ , ok := impl .(AppBuildableComponentSpec )
671
+ if wantMatch && ! ok {
672
+ t .Fatalf ("%T should match interface" , impl )
673
+ } else if ! wantMatch && ok {
674
+ t .Fatalf ("%T should NOT match interface" , impl )
675
+ }
676
+ }
677
+ })
678
+
679
+ t .Run ("AppDockerBuildableComponentSpec" , func (t * testing.T ) {
680
+ for impl , wantMatch := range map [any ]bool {
681
+ & AppServiceSpec {}: true ,
682
+ & AppWorkerSpec {}: true ,
683
+ & AppJobSpec {}: true ,
684
+ & AppStaticSiteSpec {}: true ,
685
+
686
+ & AppFunctionsSpec {}: false ,
687
+ & AppDatabaseSpec {}: false ,
688
+ } {
689
+ _ , ok := impl .(AppDockerBuildableComponentSpec )
690
+ if wantMatch && ! ok {
691
+ t .Fatalf ("%T should match interface" , impl )
692
+ } else if ! wantMatch && ok {
693
+ t .Fatalf ("%T should NOT match interface" , impl )
694
+ }
695
+ }
696
+ })
697
+
698
+ t .Run ("AppCNBBuildableComponentSpec" , func (t * testing.T ) {
699
+ for impl , wantMatch := range map [any ]bool {
700
+ & AppServiceSpec {}: true ,
701
+ & AppWorkerSpec {}: true ,
702
+ & AppJobSpec {}: true ,
703
+ & AppStaticSiteSpec {}: true ,
704
+
705
+ & AppFunctionsSpec {}: false ,
706
+ & AppDatabaseSpec {}: false ,
666
707
} {
667
- if _ , ok := impl .(AppBuildableComponentSpec ); ! ok {
708
+ _ , ok := impl .(AppCNBBuildableComponentSpec )
709
+ if wantMatch && ! ok {
668
710
t .Fatalf ("%T should match interface" , impl )
711
+ } else if ! wantMatch && ok {
712
+ t .Fatalf ("%T should NOT match interface" , impl )
669
713
}
670
714
}
671
715
})
672
716
673
717
t .Run ("AppContainerComponentSpec" , func (t * testing.T ) {
674
- for _ , impl := range []interface {}{
675
- & AppServiceSpec {},
676
- & AppWorkerSpec {},
677
- & AppJobSpec {},
718
+ for impl , wantMatch := range map [any ]bool {
719
+ & AppServiceSpec {}: true ,
720
+ & AppWorkerSpec {}: true ,
721
+ & AppJobSpec {}: true ,
722
+
723
+ & AppStaticSiteSpec {}: false ,
724
+ & AppFunctionsSpec {}: false ,
725
+ & AppDatabaseSpec {}: false ,
678
726
} {
679
- if _ , ok := impl .(AppContainerComponentSpec ); ! ok {
727
+ _ , ok := impl .(AppContainerComponentSpec )
728
+ if wantMatch && ! ok {
680
729
t .Fatalf ("%T should match interface" , impl )
730
+ } else if ! wantMatch && ok {
731
+ t .Fatalf ("%T should NOT match interface" , impl )
681
732
}
682
733
}
683
734
})
684
735
685
736
t .Run ("AppRoutableComponentSpec" , func (t * testing.T ) {
686
- for _ , impl := range []interface {}{
687
- & AppServiceSpec {},
688
- & AppStaticSiteSpec {},
689
- & AppFunctionsSpec {},
737
+ for impl , wantMatch := range map [any ]bool {
738
+ & AppServiceSpec {}: true ,
739
+ & AppStaticSiteSpec {}: true ,
740
+ & AppFunctionsSpec {}: true ,
741
+
742
+ & AppWorkerSpec {}: false ,
743
+ & AppJobSpec {}: false ,
744
+ & AppDatabaseSpec {}: false ,
690
745
} {
691
- if _ , ok := impl .(AppRoutableComponentSpec ); ! ok {
746
+ _ , ok := impl .(AppRoutableComponentSpec )
747
+ if wantMatch && ! ok {
692
748
t .Fatalf ("%T should match interface" , impl )
749
+ } else if ! wantMatch && ok {
750
+ t .Fatalf ("%T should NOT match interface" , impl )
693
751
}
694
752
}
695
753
})
@@ -717,6 +775,20 @@ func TestApps_Interfaces(t *testing.T) {
717
775
t .Fatalf ("%T should match interface" , impl )
718
776
}
719
777
}
778
+ for impl , wantMatch := range map [any ]bool {
779
+ & GitSourceSpec {}: true ,
780
+ & GitHubSourceSpec {}: true ,
781
+ & GitLabSourceSpec {}: true ,
782
+
783
+ & ImageSourceSpec {}: false ,
784
+ } {
785
+ _ , ok := impl .(VCSSourceSpec )
786
+ if wantMatch && ! ok {
787
+ t .Fatalf ("%T should match interface" , impl )
788
+ } else if ! wantMatch && ok {
789
+ t .Fatalf ("%T should NOT match interface" , impl )
790
+ }
791
+ }
720
792
})
721
793
}
722
794
0 commit comments