github.com/upcmd/up@v0.8.1-0.20230108151705-ad8b797bf04f/tests/module.go (about)

     1  // Ultimate Provisioner: UP cmd
     2  // Copyright (c) 2019 Stephen Cheng and contributors
     3  
     4  /* This Source Code Form is subject to the terms of the Mozilla Public
     5   * License, v. 2.0. If a copy of the MPL was not distributed with this
     6   * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
     7  
     8  package tests
     9  
    10  import (
    11  	"github.com/upcmd/up/biz/impl"
    12  	u "github.com/upcmd/up/utils"
    13  	"os"
    14  )
    15  
    16  //mock required settings
    17  func SetupMx(dirpath string) *u.UpConfig {
    18  	cfg := u.NewUpConfig(dirpath, "")
    19  	cfg.Secure = &u.SecureSetting{Type: "default_aes", Key: "enc_key"}
    20  	cfg.RefDir = dirpath
    21  	cfg.WorkDir = "refdir"
    22  	cfg.InitConfig()
    23  	u.MainConfig = cfg
    24  	wkdir := cfg.AbsWorkDir
    25  	u.Pln("work dir:", wkdir)
    26  	impl.SetBaseDir(wkdir)
    27  	os.Chdir(wkdir)
    28  	cfg.ShowCoreConfig("moduletest")
    29  	u.Ppmsgvvvvhint("core config", cfg)
    30  	u.Pln(" :test task file:", cfg.TaskFile)
    31  	u.Pln(" :release version:", cfg.Version)
    32  	u.Pln(" :verbose level:", cfg.Verbose)
    33  	return cfg
    34  }