@@ -12,7 +12,10 @@ import (
1212 "github.com/acorn-io/baaah/pkg/typed"
1313 v1 "github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1"
1414 "github.com/acorn-io/z"
15+ "github.com/hexops/autogold/v2"
16+ "github.com/hexops/valast"
1517 "github.com/stretchr/testify/assert"
18+ "github.com/stretchr/testify/require"
1619)
1720
1821func TestReadMeInfoIcon (t * testing.T ) {
@@ -2966,6 +2969,109 @@ containers: default: image: "foo"
29662969 assert .Equal (t , v1 .Probes (nil ), spec .Containers ["default" ].Probes )
29672970}
29682971
2972+ func TestComputeMemOnNested (t * testing.T ) {
2973+ appImage , err := NewAppDefinition ([]byte (`
2974+ services: sdef: {
2975+ class: "foo"
2976+ mem: 1G
2977+ }
2978+ services: snodef: {
2979+ class: {
2980+ "foo": "bar"
2981+ }
2982+ mem: {
2983+ "foo": 1G
2984+ }
2985+ }
2986+ acorns: def: {
2987+ class: "foo"
2988+ mem: 1G
2989+ }
2990+ acorns: nodef: {
2991+ class: {
2992+ "foo": "bar"
2993+ }
2994+ mem: {
2995+ "foo": 1G
2996+ }
2997+ }` ))
2998+ if err != nil {
2999+ t .Fatal (err )
3000+ }
3001+
3002+ appSpec , err := appImage .AppSpec ()
3003+ require .NoError (t , err )
3004+
3005+ autogold .Expect (& v1.AppSpec {
3006+ Labels : map [string ]string {},
3007+ Annotations : map [string ]string {},
3008+ Containers : map [string ]v1.Container {},
3009+ Jobs : map [string ]v1.Container {},
3010+ Images : map [string ]v1.Image {},
3011+ Volumes : map [string ]v1.VolumeRequest {},
3012+ Secrets : map [string ]v1.Secret {},
3013+ Acorns : map [string ]v1.Acorn {
3014+ "def" : {
3015+ Labels : v1.ScopedLabels {},
3016+ Annotations : v1.ScopedLabels {},
3017+ Profiles : []string {},
3018+ DeployArgs : v1.GenericMap {},
3019+ Publish : v1.PortBindings {},
3020+ Secrets : v1.SecretBindings {},
3021+ Volumes : v1.VolumeBindings {},
3022+ Links : v1.ServiceBindings {},
3023+ AutoUpgrade : valast .Addr (false ).(* bool ),
3024+ NotifyUpgrade : valast .Addr (false ).(* bool ),
3025+ Memory : v1.MemoryMap {"" : valast .Addr (int64 (1000000000 )).(* int64 )},
3026+ ComputeClasses : v1.ComputeClassMap {"" : "foo" },
3027+ Permissions : map [string ]v1.Permissions {},
3028+ },
3029+ "nodef" : {
3030+ Labels : v1.ScopedLabels {},
3031+ Annotations : v1.ScopedLabels {},
3032+ Profiles : []string {},
3033+ DeployArgs : v1.GenericMap {},
3034+ Publish : v1.PortBindings {},
3035+ Secrets : v1.SecretBindings {},
3036+ Volumes : v1.VolumeBindings {},
3037+ Links : v1.ServiceBindings {},
3038+ AutoUpgrade : valast .Addr (false ).(* bool ),
3039+ NotifyUpgrade : valast .Addr (false ).(* bool ),
3040+ Memory : v1.MemoryMap {"foo" : valast .Addr (int64 (1000000000 )).(* int64 )},
3041+ ComputeClasses : v1.ComputeClassMap {"foo" : "bar" },
3042+ Permissions : map [string ]v1.Permissions {},
3043+ },
3044+ },
3045+ Routers : map [string ]v1.Router {},
3046+ Services : map [string ]v1.Service {
3047+ "sdef" : {
3048+ Labels : v1.ScopedLabels {},
3049+ Annotations : v1.ScopedLabels {},
3050+ ServiceArgs : v1.GenericMap {},
3051+ Secrets : v1.SecretBindings {},
3052+ Links : v1.ServiceBindings {},
3053+ AutoUpgrade : valast .Addr (false ).(* bool ),
3054+ NotifyUpgrade : valast .Addr (false ).(* bool ),
3055+ Memory : v1.MemoryMap {"" : valast .Addr (int64 (1000000000 )).(* int64 )},
3056+ ComputeClasses : v1.ComputeClassMap {"" : "foo" },
3057+ Permissions : map [string ]v1.Permissions {},
3058+ },
3059+ "snodef" : {
3060+ Labels : v1.ScopedLabels {},
3061+ Annotations : v1.ScopedLabels {},
3062+ ServiceArgs : v1.GenericMap {},
3063+ Secrets : v1.SecretBindings {},
3064+ Links : v1.ServiceBindings {},
3065+ AutoUpgrade : valast .Addr (false ).(* bool ),
3066+ NotifyUpgrade : valast .Addr (false ).(* bool ),
3067+ Memory : v1.MemoryMap {"foo" : valast .Addr (int64 (1000000000 )).(* int64 )},
3068+ ComputeClasses : v1.ComputeClassMap {"foo" : "bar" },
3069+ Permissions : map [string ]v1.Permissions {},
3070+ },
3071+ },
3072+ }).Equal (t , appSpec )
3073+ }
3074+
29693075func TestNestedScopedLabels (t * testing.T ) {
29703076 // labels and annotations on a acorn are both unmarshalled into a ScopedLabels struct, which is just a slice
29713077 // Similar to ports, in the Acornfile you can define them using an object syntax or short-form string syntax.
0 commit comments