@@ -3089,3 +3089,69 @@ func TestWorkspacesAutoDestroyDuration(t *testing.T) {
3089
3089
require .Equal (t , wTest .InheritsProjectAutoDestroy , false )
3090
3090
})
3091
3091
}
3092
+
3093
+ func TestWorkspaces_effectiveTagBindingsInheritedFrom (t * testing.T ) {
3094
+ skipUnlessBeta (t )
3095
+
3096
+ client := testClient (t )
3097
+ ctx := context .Background ()
3098
+
3099
+ orgTest , orgTestCleanup := createOrganization (t , client )
3100
+ t .Cleanup (orgTestCleanup )
3101
+
3102
+ projTest , projTestCleanup := createProject (t , client , orgTest )
3103
+ t .Cleanup (projTestCleanup )
3104
+
3105
+ ws , wsCleanup := createWorkspaceWithOptions (t , client , orgTest , WorkspaceCreateOptions {
3106
+ Name : String ("mycoolworkspace" ),
3107
+ Project : projTest ,
3108
+ })
3109
+ t .Cleanup (wsCleanup )
3110
+
3111
+ _ , err := client .Workspaces .AddTagBindings (ctx , ws .ID , WorkspaceAddTagBindingsOptions {
3112
+ TagBindings : []* TagBinding {
3113
+ {
3114
+ Key : "a" ,
3115
+ Value : "1" ,
3116
+ },
3117
+ {
3118
+ Key : "b" ,
3119
+ Value : "2" ,
3120
+ },
3121
+ },
3122
+ })
3123
+ require .NoError (t , err )
3124
+
3125
+ t .Run ("when no tags are inherited from the project" , func (t * testing.T ) {
3126
+ effectiveBindings , err := client .Workspaces .ListEffectiveTagBindings (ctx , ws .ID )
3127
+ require .NoError (t , err )
3128
+
3129
+ for _ , binding := range effectiveBindings {
3130
+ require .Nil (t , binding .Links )
3131
+ }
3132
+ })
3133
+
3134
+ t .Run ("when tags are inherited from the project" , func (t * testing.T ) {
3135
+ _ , err := client .Projects .AddTagBindings (ctx , projTest .ID , ProjectAddTagBindingsOptions {
3136
+ TagBindings : []* TagBinding {
3137
+ {
3138
+ Key : "inherited" ,
3139
+ Value : "foo" ,
3140
+ },
3141
+ },
3142
+ })
3143
+ require .NoError (t , err )
3144
+
3145
+ effectiveBindings , err := client .Workspaces .ListEffectiveTagBindings (ctx , ws .ID )
3146
+ require .NoError (t , err )
3147
+
3148
+ for _ , binding := range effectiveBindings {
3149
+ if binding .Key == "inherited" {
3150
+ require .NotNil (t , binding .Links )
3151
+ require .NotNil (t , binding .Links ["inherited-from" ])
3152
+ } else {
3153
+ require .Nil (t , binding .Links )
3154
+ }
3155
+ }
3156
+ })
3157
+ }
0 commit comments