@@ -515,3 +515,133 @@ func TestActionsService_GetCacheUsageForEnterprise_notFound(t *testing.T) {
515515 t .Errorf ("Actions.GetTotalCacheUsageForEnterprise return %+v, want nil" , caches )
516516 }
517517}
518+
519+ func TestActionsCache_Marshal (t * testing.T ) {
520+ testJSONMarshal (t , & ActionsCache {}, "{}" )
521+
522+ u := & ActionsCache {
523+ ID : Int64 (1 ),
524+ Ref : String ("refAction" ),
525+ Key : String ("key1" ),
526+ Version : String ("alpha" ),
527+ LastAccessedAt : & Timestamp {referenceTime },
528+ CreatedAt : & Timestamp {referenceTime },
529+ SizeInBytes : Int64 (1 ),
530+ }
531+
532+ want := `{
533+ "id": 1,
534+ "ref": "refAction",
535+ "key": "key1",
536+ "version": "alpha",
537+ "last_accessed_at": ` + referenceTimeStr + `,
538+ "created_at": ` + referenceTimeStr + `,
539+ "size_in_bytes": 1
540+ }`
541+
542+ testJSONMarshal (t , u , want )
543+ }
544+
545+ func TestActionsCacheList_Marshal (t * testing.T ) {
546+ testJSONMarshal (t , & ActionsCacheList {}, "{}" )
547+
548+ u := & ActionsCacheList {
549+ TotalCount : 2 ,
550+ ActionsCaches : []* ActionsCache {
551+ {
552+ ID : Int64 (1 ),
553+ Key : String ("key1" ),
554+ Version : String ("alpha" ),
555+ LastAccessedAt : & Timestamp {referenceTime },
556+ CreatedAt : & Timestamp {referenceTime },
557+ SizeInBytes : Int64 (1 ),
558+ },
559+ {
560+ ID : Int64 (2 ),
561+ Ref : String ("refAction" ),
562+ LastAccessedAt : & Timestamp {referenceTime },
563+ CreatedAt : & Timestamp {referenceTime },
564+ SizeInBytes : Int64 (1 ),
565+ },
566+ },
567+ }
568+ want := `{
569+ "total_count": 2,
570+ "actions_caches": [{
571+ "id": 1,
572+ "key": "key1",
573+ "version": "alpha",
574+ "last_accessed_at": ` + referenceTimeStr + `,
575+ "created_at": ` + referenceTimeStr + `,
576+ "size_in_bytes": 1
577+ },
578+ {
579+ "id": 2,
580+ "ref": "refAction",
581+ "last_accessed_at": ` + referenceTimeStr + `,
582+ "created_at": ` + referenceTimeStr + `,
583+ "size_in_bytes": 1
584+ }]
585+ }`
586+ testJSONMarshal (t , u , want )
587+ }
588+
589+ func TestActionsCacheUsage_Marshal (t * testing.T ) {
590+ testJSONMarshal (t , & ActionsCacheUsage {}, "{}" )
591+
592+ u := & ActionsCacheUsage {
593+ FullName : "cache_usage1" ,
594+ ActiveCachesSizeInBytes : 2 ,
595+ ActiveCachesCount : 2 ,
596+ }
597+
598+ want := `{
599+ "full_name": "cache_usage1",
600+ "active_caches_size_in_bytes": 2,
601+ "active_caches_count": 2
602+ }`
603+
604+ testJSONMarshal (t , u , want )
605+ }
606+
607+ func TestActionsCacheUsageList_Marshal (t * testing.T ) {
608+ testJSONMarshal (t , & ActionsCacheUsageList {}, "{}" )
609+
610+ u := & ActionsCacheUsageList {
611+ TotalCount : 1 ,
612+ RepoCacheUsage : []* ActionsCacheUsage {
613+ {
614+ FullName : "cache_usage1" ,
615+ ActiveCachesSizeInBytes : 2 ,
616+ ActiveCachesCount : 2 ,
617+ },
618+ },
619+ }
620+
621+ want := `{
622+ "total_count": 1,
623+ "repository_cache_usages": [{
624+ "full_name": "cache_usage1",
625+ "active_caches_size_in_bytes": 2,
626+ "active_caches_count": 2
627+ }]
628+ }`
629+
630+ testJSONMarshal (t , u , want )
631+ }
632+
633+ func TestTotalCacheUsage_Marshal (t * testing.T ) {
634+ testJSONMarshal (t , & TotalCacheUsage {}, "{}" )
635+
636+ u := & TotalCacheUsage {
637+ TotalActiveCachesUsageSizeInBytes : 2 ,
638+ TotalActiveCachesCount : 2 ,
639+ }
640+
641+ want := `{
642+ "total_active_caches_size_in_bytes": 2,
643+ "total_active_caches_count": 2
644+ }`
645+
646+ testJSONMarshal (t , u , want )
647+ }
0 commit comments