(t *testing.T)
| 103 | } |
| 104 | |
| 105 | func TestEncodePassword(t *testing.T) { |
| 106 | want := EncodePassword("123456", "rands") |
| 107 | tests := []struct { |
| 108 | name string |
| 109 | password string |
| 110 | rands string |
| 111 | wantEqual bool |
| 112 | }{ |
| 113 | { |
| 114 | name: "correct", |
| 115 | password: "123456", |
| 116 | rands: "rands", |
| 117 | wantEqual: true, |
| 118 | }, |
| 119 | |
| 120 | { |
| 121 | name: "wrong password", |
| 122 | password: "111333", |
| 123 | rands: "rands", |
| 124 | wantEqual: false, |
| 125 | }, |
| 126 | { |
| 127 | name: "wrong salt", |
| 128 | password: "111333", |
| 129 | rands: "salt", |
| 130 | wantEqual: false, |
| 131 | }, |
| 132 | } |
| 133 | for _, test := range tests { |
| 134 | t.Run(test.name, func(t *testing.T) { |
| 135 | got := EncodePassword(test.password, test.rands) |
| 136 | if test.wantEqual { |
| 137 | assert.Equal(t, want, got) |
| 138 | } else { |
| 139 | assert.NotEqual(t, want, got) |
| 140 | } |
| 141 | }) |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | func TestValidatePassword(t *testing.T) { |
| 146 | want := EncodePassword("123456", "rands") |
nothing calls this directly
no test coverage detected