~andreserl/maas/lp1604169_2.0

« back to all changes in this revision

Viewing changes to src/maasserver/static/js/angular/controllers/tests/test_node_details_storage.js

  • Committer: MAAS Lander
  • Author(s): Blake Rouse
  • Date: 2016-07-11 17:50:13 UTC
  • mfrom: (5150.1.1 fix-1600198-2.0)
  • Revision ID: maas_lander-20160711175013-f19k577dzaqvf5fy
[r=blake-rouse][bug=1600198][author=blake-rouse] Prevent bcache creation on devices with partitions. Inform the user in the tooltip why bcache creation is disabled.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3202
3202
            });
3203
3203
    });
3204
3204
 
 
3205
    describe("getCannotCreateBcacheMsg", function() {
 
3206
 
 
3207
        it("returns msg if no cachesets",
 
3208
            function() {
 
3209
                var controller = makeController();
 
3210
                $scope.available = [
 
3211
                    {
 
3212
                        fstype: null,
 
3213
                        $selected: true,
 
3214
                        has_partitions: false
 
3215
                    }
 
3216
                ];
 
3217
                $scope.cachesets = [];
 
3218
                expect($scope.getCannotCreateBcacheMsg()).toBe(
 
3219
                    "Create at least one cache set to create bcache");
 
3220
            });
 
3221
 
 
3222
        it("returns msg if two selected", function() {
 
3223
            var controller = makeController();
 
3224
            $scope.cachesets = [{}];
 
3225
            $scope.available = [ { $selected: true }, { $selected: true }];
 
3226
            expect($scope.getCannotCreateBcacheMsg()).toBe(
 
3227
                "Select only one available device to create bcache");
 
3228
        });
 
3229
 
 
3230
        it("returns msg if selected has fstype", function() {
 
3231
            var controller = makeController();
 
3232
            $scope.available = [
 
3233
                {
 
3234
                    fstype: "ext4",
 
3235
                    $selected: true,
 
3236
                    has_partitions: false
 
3237
                }
 
3238
            ];
 
3239
            $scope.cachesets = [{}];
 
3240
 
 
3241
            expect($scope.getCannotCreateBcacheMsg()).toBe(
 
3242
                "Device is formatted; unformat the device to create bcache");
 
3243
        });
 
3244
 
 
3245
        it("returns msg if selected is volume group", function() {
 
3246
            var controller = makeController();
 
3247
            $scope.available = [
 
3248
                {
 
3249
                    type: "lvm-vg",
 
3250
                    fstype: null,
 
3251
                    $selected: true,
 
3252
                    has_partitions: false
 
3253
                }
 
3254
            ];
 
3255
            $scope.cachesets = [{}];
 
3256
            expect($scope.getCannotCreateBcacheMsg()).toBe(
 
3257
                "Cannot use a logical volume as a backing device for bcache.");
 
3258
        });
 
3259
 
 
3260
        it("returns msg if selected has partitions", function() {
 
3261
            var controller = makeController();
 
3262
            $scope.available = [
 
3263
                {
 
3264
                    fstype: null,
 
3265
                    $selected: true,
 
3266
                    has_partitions: true
 
3267
                }
 
3268
            ];
 
3269
            $scope.cachesets = [{}];
 
3270
            expect($scope.getCannotCreateBcacheMsg()).toBe(
 
3271
                "Device has already been partitioned; create a " +
 
3272
                "new partition to use as the bcache backing " +
 
3273
                "device");
 
3274
        });
 
3275
 
 
3276
        it("returns null if selected is valid",
 
3277
            function() {
 
3278
                var controller = makeController();
 
3279
                $scope.available = [
 
3280
                    {
 
3281
                        fstype: null,
 
3282
                        $selected: true,
 
3283
                        has_partitions: false
 
3284
                    }
 
3285
                ];
 
3286
                $scope.cachesets = [{}];
 
3287
                expect($scope.getCannotCreateBcacheMsg()).toBeNull();
 
3288
            });
 
3289
    });
 
3290
 
3205
3291
    describe("canCreateBcache", function() {
3206
3292
 
3207
3293
        it("returns false when isAvailableDisabled is true", function() {
3227
3313
            $scope.available = [
3228
3314
                {
3229
3315
                    fstype: "ext4",
3230
 
                    $selected: true
 
3316
                    $selected: true,
 
3317
                    has_partitions: false
3231
3318
                }
3232
3319
            ];
3233
3320
            $scope.cachesets = [{}];
3243
3330
                {
3244
3331
                    type: "lvm-vg",
3245
3332
                    fstype: null,
3246
 
                    $selected: true
 
3333
                    $selected: true,
 
3334
                    has_partitions: false
 
3335
                }
 
3336
            ];
 
3337
            $scope.cachesets = [{}];
 
3338
            $scope.isSuperUser = function() { return true; };
 
3339
 
 
3340
            expect($scope.canCreateBcache()).toBe(false);
 
3341
        });
 
3342
 
 
3343
        it("returns false if selected has partitions", function() {
 
3344
            var controller = makeController();
 
3345
            spyOn($scope, "isAvailableDisabled").and.returnValue(false);
 
3346
            $scope.available = [
 
3347
                {
 
3348
                    fstype: null,
 
3349
                    $selected: true,
 
3350
                    has_partitions: true
3247
3351
                }
3248
3352
            ];
3249
3353
            $scope.cachesets = [{}];
3259
3363
                $scope.available = [
3260
3364
                    {
3261
3365
                        fstype: null,
3262
 
                        $selected: true
 
3366
                        $selected: true,
 
3367
                        has_partitions: false
3263
3368
                    }
3264
3369
                ];
3265
3370
                $scope.cachesets = [];
3275
3380
                $scope.available = [
3276
3381
                    {
3277
3382
                        fstype: null,
3278
 
                        $selected: true
 
3383
                        $selected: true,
 
3384
                        has_partitions: false
3279
3385
                    }
3280
3386
                ];
3281
3387
                $scope.cachesets = [{}];
3291
3397
                $scope.available = [
3292
3398
                    {
3293
3399
                        fstype: null,
3294
 
                        $selected: true
 
3400
                        $selected: true,
 
3401
                        has_partitions: false
3295
3402
                    }
3296
3403
                ];
3297
3404
                $scope.cachesets = [{}];