github.com/spline-fu/mattermost-server@v4.10.10+incompatible/utils/file_backend_s3_test.go (about)

     1  // Copyright (c) 2018-present Mattermost, Inc. All Rights Reserved.
     2  // See License.txt for license information.
     3  
     4  package utils
     5  
     6  import (
     7  	"testing"
     8  
     9  	"github.com/mattermost/mattermost-server/model"
    10  )
    11  
    12  func TestCheckMandatoryS3Fields(t *testing.T) {
    13  	cfg := model.FileSettings{}
    14  
    15  	err := CheckMandatoryS3Fields(&cfg)
    16  	if err == nil || err.Message != "api.admin.test_s3.missing_s3_bucket" {
    17  		t.Fatal("should've failed with missing s3 bucket")
    18  	}
    19  
    20  	cfg.AmazonS3Bucket = "test-mm"
    21  	err = CheckMandatoryS3Fields(&cfg)
    22  	if err != nil {
    23  		t.Fatal("should've not failed")
    24  	}
    25  
    26  	cfg.AmazonS3Endpoint = ""
    27  	err = CheckMandatoryS3Fields(&cfg)
    28  	if err != nil || cfg.AmazonS3Endpoint != "s3.amazonaws.com" {
    29  		t.Fatal("should've not failed because it should set the endpoint to the default")
    30  	}
    31  
    32  }