@@ -60,4 +60,53 @@ func Test_AddDomains(t *testing.T) {
6060 +----------+--------+-----------+----------------+
6161` , r .Hostfile ())
6262 })
63+
64+ t .Run ("Add domains uniq" , func (t * testing.T ) {
65+ r := NewRunner (t , cmd , "add_uniq" )
66+ defer r .Clean ()
67+
68+ r .Run ("hostctl add domains awesome same.domain.loc --ip 3.3.3.3" ).
69+ Run ("hostctl add domains awesome same.domain.loc --ip 3.3.3.3" ).
70+ Containsf (`
71+ [ℹ] Using hosts file: %s
72+
73+ [✔] Domains 'same.domain.loc' added.
74+
75+ +---------+--------+---------+-----------------+
76+ | PROFILE | STATUS | IP | DOMAIN |
77+ +---------+--------+---------+-----------------+
78+ | awesome | on | 3.3.3.3 | same.domain.loc |
79+ +---------+--------+---------+-----------------+
80+ ` , r .Hostfile ())
81+ })
82+
83+ t .Run ("Add domains uniq per profile" , func (t * testing.T ) {
84+ r := NewRunner (t , cmd , "multi_profile" )
85+ defer r .Clean ()
86+
87+ r .Run ("hostctl add domains another same.domain.loc --ip 3.3.3.3" ).
88+ Run ("hostctl add domains another same.domain.loc --ip 3.3.3.3" ).
89+ Run ("hostctl add domains awesome same.domain.loc --ip 3.3.3.3" ).
90+ Run ("hostctl add domains awesome same.domain.loc --ip 3.3.3.3" ).
91+ Run ("hostctl list another" ).
92+ Containsf (`
93+ [ℹ] Using hosts file: %s
94+
95+ +---------+--------+---------+-----------------+
96+ | PROFILE | STATUS | IP | DOMAIN |
97+ +---------+--------+---------+-----------------+
98+ | another | on | 3.3.3.3 | same.domain.loc |
99+ +---------+--------+---------+-----------------+
100+ ` , r .Hostfile ()).
101+ Run ("hostctl list awesome" ).
102+ Containsf (`
103+ [ℹ] Using hosts file: %s
104+
105+ +---------+--------+---------+-----------------+
106+ | PROFILE | STATUS | IP | DOMAIN |
107+ +---------+--------+---------+-----------------+
108+ | awesome | on | 3.3.3.3 | same.domain.loc |
109+ +---------+--------+---------+-----------------+
110+ ` , r .Hostfile ())
111+ })
63112}
0 commit comments