@@ -4,10 +4,12 @@ import (
44 "context"
55 "fmt"
66 "strconv"
7+ "strings"
78 "testing"
89
910 tcacctest "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/acctest"
1011 tccommon "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/common"
12+ "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper"
1113 svcvod "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/services/vod"
1214
1315 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
@@ -53,7 +55,6 @@ func TestAccTencentCloudVodAdaptiveDynamicStreamingTemplateResource(t *testing.T
5355 {
5456 Config : testAccVodAdaptiveDynamicStreamingTemplate ,
5557 Check : resource .ComposeTestCheckFunc (
56- testAccCheckVodAdaptiveDynamicStreamingTemplateExists ("tencentcloud_vod_adaptive_dynamic_streaming_template.foo" ),
5758 resource .TestCheckResourceAttr ("tencentcloud_vod_adaptive_dynamic_streaming_template.foo" , "format" , "HLS" ),
5859 resource .TestCheckResourceAttr ("tencentcloud_vod_adaptive_dynamic_streaming_template.foo" , "name" , "tf-adaptive" ),
5960 resource .TestCheckResourceAttr ("tencentcloud_vod_adaptive_dynamic_streaming_template.foo" , "drm_type" , "SimpleAES" ),
@@ -81,6 +82,7 @@ func TestAccTencentCloudVodAdaptiveDynamicStreamingTemplateResource(t *testing.T
8182 resource .TestCheckResourceAttr ("tencentcloud_vod_adaptive_dynamic_streaming_template.foo" , "stream_info.1.remove_audio" , "true" ),
8283 resource .TestCheckResourceAttrSet ("tencentcloud_vod_adaptive_dynamic_streaming_template.foo" , "create_time" ),
8384 resource .TestCheckResourceAttrSet ("tencentcloud_vod_adaptive_dynamic_streaming_template.foo" , "update_time" ),
85+ resource .TestCheckResourceAttrSet ("tencentcloud_vod_adaptive_dynamic_streaming_template.foo" , "sub_app_id" ),
8486 ),
8587 },
8688 {
@@ -104,13 +106,14 @@ func TestAccTencentCloudVodAdaptiveDynamicStreamingTemplateResource(t *testing.T
104106 resource .TestCheckResourceAttr ("tencentcloud_vod_adaptive_dynamic_streaming_template.foo" , "stream_info.0.audio.0.sample_rate" , "44100" ),
105107 resource .TestCheckResourceAttr ("tencentcloud_vod_adaptive_dynamic_streaming_template.foo" , "stream_info.0.audio.0.audio_channel" , "dual" ),
106108 resource .TestCheckResourceAttr ("tencentcloud_vod_adaptive_dynamic_streaming_template.foo" , "stream_info.0.remove_audio" , "false" ),
109+ resource .TestCheckResourceAttrSet ("tencentcloud_vod_adaptive_dynamic_streaming_template.foo" , "sub_app_id" ),
110+ resource .TestCheckResourceAttr ("tencentcloud_vod_adaptive_dynamic_streaming_template.foo" , "stream_info.0.tehd_config.0.type" , "TEHD-100" ),
107111 ),
108112 },
109113 {
110- ResourceName : "tencentcloud_vod_adaptive_dynamic_streaming_template.foo" ,
111- ImportState : true ,
112- ImportStateVerify : true ,
113- ImportStateVerifyIgnore : []string {"sub_app_id" },
114+ ResourceName : "tencentcloud_vod_adaptive_dynamic_streaming_template.foo" ,
115+ ImportState : true ,
116+ ImportStateVerify : true ,
114117 },
115118 },
116119 })
@@ -125,11 +128,13 @@ func testAccCheckVodAdaptiveDynamicStreamingTemplateDestroy(s *terraform.State)
125128 if rs .Type != "tencentcloud_vod_adaptive_dynamic_streaming_template" {
126129 continue
127130 }
128- var (
129- filter = map [string ]interface {}{
130- "definitions" : []string {rs .Primary .ID },
131- }
132- )
131+ idSplit := strings .Split (rs .Primary .ID , tccommon .FILED_SP )
132+ subAppId := helper .StrToInt (idSplit [0 ])
133+ definition := idSplit [1 ]
134+ filter := map [string ]interface {}{
135+ "definitions" : []string {definition },
136+ "sub_appid" : subAppId ,
137+ }
133138
134139 templates , err := vodService .DescribeAdaptiveDynamicStreamingTemplatesByFilter (ctx , filter )
135140 if err != nil {
@@ -156,9 +161,13 @@ func testAccCheckVodAdaptiveDynamicStreamingTemplateExists(n string) resource.Te
156161 return fmt .Errorf ("vod adaptive dynamic streaming template id is not set" )
157162 }
158163 vodService := svcvod .NewVodService (tcacctest .AccProvider .Meta ().(tccommon.ProviderMeta ).GetAPIV3Conn ())
164+ idSplit := strings .Split (rs .Primary .ID , tccommon .FILED_SP )
165+ subAppId := helper .StrToInt (idSplit [0 ])
166+ definition := idSplit [1 ]
159167 var (
160168 filter = map [string ]interface {}{
161- "definitions" : []string {rs .Primary .ID },
169+ "definitions" : []string {definition },
170+ "sub_appid" : subAppId ,
162171 }
163172 )
164173
@@ -174,9 +183,16 @@ func testAccCheckVodAdaptiveDynamicStreamingTemplateExists(n string) resource.Te
174183}
175184
176185const testAccVodAdaptiveDynamicStreamingTemplate = `
186+ resource "tencentcloud_vod_sub_application" "sub_application" {
187+ name = "adaptive-subapplication"
188+ status = "On"
189+ description = "this is sub application"
190+ }
191+
177192resource "tencentcloud_vod_adaptive_dynamic_streaming_template" "foo" {
178193 format = "HLS"
179194 name = "tf-adaptive"
195+ sub_app_id = tonumber(split("#", tencentcloud_vod_sub_application.sub_application.id)[1])
180196 drm_type = "SimpleAES"
181197 disable_higher_video_bitrate = false
182198 disable_higher_video_resolution = false
@@ -212,9 +228,16 @@ resource "tencentcloud_vod_adaptive_dynamic_streaming_template" "foo" {
212228`
213229
214230const testAccVodAdaptiveDynamicStreamingTemplateUpdate = `
231+ resource "tencentcloud_vod_sub_application" "sub_application" {
232+ name = "adaptive-subapplication"
233+ status = "On"
234+ description = "this is sub application"
235+ }
236+
215237resource "tencentcloud_vod_adaptive_dynamic_streaming_template" "foo" {
216238 format = "HLS"
217239 name = "tf-adaptive-update"
240+ sub_app_id = tonumber(split("#", tencentcloud_vod_sub_application.sub_application.id)[1])
218241 drm_type = "SimpleAES"
219242 disable_higher_video_bitrate = true
220243 disable_higher_video_resolution = true
@@ -237,6 +260,9 @@ resource "tencentcloud_vod_adaptive_dynamic_streaming_template" "foo" {
237260 audio_channel = "dual"
238261 }
239262 remove_audio = false
263+ tehd_config {
264+ type = "TEHD-100"
265+ }
240266 }
241267}
242268`
0 commit comments