github.com/gramework/gramework@v1.8.1-0.20231027140105-82555c9057f5/app_test.go (about) 1 // Copyright 2017-present Kirill Danshin and Gramework contributors 2 // Copyright 2019-present Highload LTD (UK CN: 11893420) 3 // 4 // Licensed under the Apache License, Version 2.0 (the "License"); 5 // you may not use this file except in compliance with the License. 6 // You may obtain a copy of the License at 7 // 8 // http://www.apache.org/licenses/LICENSE-2.0 9 // 10 11 package gramework 12 13 import ( 14 "testing" 15 16 "github.com/stretchr/testify/assert" 17 ) 18 19 func TestApp_SetName(t *testing.T) { 20 setName := func(n string) { 21 app := New(OptAppName(DefaultAppName)) 22 if assert.Equal(t, DefaultAppName, app.name) { 23 app.SetName(n) 24 } 25 if len(n) == 0 { 26 n = DefaultAppName 27 } 28 assert.Equal(t, n, app.name) 29 assert.Equal(t, n, app.serverBase.Name) 30 } 31 t.Run("CustomName", func(t *testing.T) { 32 setName("test_app") 33 }) 34 t.Run("EmptyName", func(t *testing.T) { 35 setName("") 36 }) 37 }