github.com/qri-io/qri@v0.10.1-0.20220104210721-c771715036cb/config/test/config.go (about) 1 package test 2 3 import ( 4 "github.com/qri-io/qfs" 5 testkeys "github.com/qri-io/qri/auth/key/test" 6 "github.com/qri-io/qri/config" 7 ) 8 9 // DefaultConfigForTesting constructs a config with precomputed keys, only used for testing. 10 func DefaultConfigForTesting() *config.Config { 11 kd := testkeys.GetKeyData(0) 12 cfg := config.DefaultConfig() 13 cfg.P2P.PrivKey = kd.EncodedPrivKey 14 cfg.P2P.PeerID = kd.EncodedPeerID 15 cfg.Profile.Peername = "default_profile_for_testing" 16 cfg.Profile.PrivKey = kd.EncodedPrivKey 17 cfg.Profile.ID = kd.EncodedPeerID 18 cfg.CLI.ColorizeOutput = false 19 cfg.Registry.Location = "" 20 return cfg 21 } 22 23 // DefaultMemConfigForTesting constructs a config with precomputed keys & settings for an in memory repo & fs, only used for testing. 24 func DefaultMemConfigForTesting() *config.Config { 25 cfg := DefaultConfigForTesting().Copy() 26 27 // add settings for in-mem filesystem 28 cfg.Filesystems = []qfs.Config{ 29 {Type: "mem"}, 30 {Type: "local"}, 31 {Type: "http"}, 32 } 33 34 // add settings for in mem repo 35 cfg.Repo.Type = "mem" 36 37 return cfg 38 } 39 40 // DefaultProfileForTesting constructs a profile with precompted keys, only used for testing. 41 // TODO (b5): move this into a new profile/test package 42 func DefaultProfileForTesting() *config.ProfilePod { 43 kd := testkeys.GetKeyData(0) 44 pro := config.DefaultProfile() 45 pro.Peername = "default_profile_for_testing" 46 pro.PrivKey = kd.EncodedPrivKey 47 pro.ID = kd.EncodedPeerID 48 return pro 49 } 50 51 // DefaultP2PForTesting constructs a p2p with precomputed keys, only used for testing. 52 func DefaultP2PForTesting() *config.P2P { 53 kd := testkeys.GetKeyData(0) 54 p := config.DefaultP2P() 55 p.BootstrapAddrs = nil 56 p.PrivKey = kd.EncodedPrivKey 57 p.PeerID = kd.EncodedPeerID 58 return p 59 }