include nizhnyNovgorod contest
Signed-off-by: Iskander Sharipov <quasilyte@gmail.com>
This commit is contained in:
parent
0fa88e6ac8
commit
49e0584f93
3 changed files with 35 additions and 12 deletions
|
@ -18,6 +18,9 @@ How to participate:
|
||||||
5. If CI tests will pass, your contribution will be merged.
|
5. If CI tests will pass, your contribution will be merged.
|
||||||
6. When PR is merged, you're awesome and can potentially win a prize.
|
6. When PR is merged, you're awesome and can potentially win a prize.
|
||||||
|
|
||||||
|
**Update**: [Nizhny Novgorod](https://vk.com/golang_nizhny) community can also participate.
|
||||||
|
Just use `nizhnyNovgorod: true` field when adding a `gopher` entry.
|
||||||
|
|
||||||
## How the winner is selected
|
## How the winner is selected
|
||||||
|
|
||||||
We print winner after tests are finished.
|
We print winner after tests are finished.
|
||||||
|
@ -30,7 +33,9 @@ Example (how "printed" winner may look like):
|
||||||
|
|
||||||
![](https://habrastorage.org/webt/kl/kk/k7/klkkk7zghbwmsuwefnaqxhyv3-y.jpeg)
|
![](https://habrastorage.org/webt/kl/kk/k7/klkkk7zghbwmsuwefnaqxhyv3-y.jpeg)
|
||||||
|
|
||||||
Pull Requests are accepted until 23:59 of September 30 (Moscow time).
|
Deadlines:
|
||||||
|
* Kazan: 23:59 of September 30 (Moscow time)
|
||||||
|
* Nizhny Novgorod: 23:59 of October 1 (Moscow time)
|
||||||
|
|
||||||
If there are less than 5 participants, we can't grant any gifts, therefore, invite your friends!
|
If there are less than 5 participants, we can't grant any gifts, therefore, invite your friends!
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,8 @@ var gophers = []gopher{
|
||||||
post: "https://vk.com/bontequero?w=wall140207068_146",
|
post: "https://vk.com/bontequero?w=wall140207068_146",
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Participants from Nizhny Novgorod (https://vk.com/golang_nizhny):
|
||||||
|
|
||||||
// Testers. Do not need to contain a valid URL in post,
|
// Testers. Do not need to contain a valid URL in post,
|
||||||
// but should use `tester: true` and can't win a prize.
|
// but should use `tester: true` and can't win a prize.
|
||||||
{
|
{
|
||||||
|
@ -84,6 +86,10 @@ type gopher struct {
|
||||||
|
|
||||||
// tester can submit invalid post string, but can't win a prize.
|
// tester can submit invalid post string, but can't win a prize.
|
||||||
tester bool
|
tester bool
|
||||||
|
|
||||||
|
// nizhnyNovgorod tells whether a participant is a part of Nizhny Novgorod
|
||||||
|
// Go community.
|
||||||
|
nizhnyNovgorod bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// key returns a hopefully unique participant key.
|
// key returns a hopefully unique participant key.
|
||||||
|
|
|
@ -6,10 +6,19 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func runWinnerTest(t *testing.T, gophers []gopher) {
|
||||||
|
if len(gophers) >= 5 {
|
||||||
|
rand.Seed(time.Now().UTC().UnixNano())
|
||||||
|
winner := rand.Intn(len(gophers))
|
||||||
|
t.Logf("The winner is: %s!", gophers[winner].key())
|
||||||
|
} else {
|
||||||
|
t.Log("Not enough participants")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestWinner(t *testing.T) {
|
func TestWinner(t *testing.T) {
|
||||||
// filtered is a list of participating gophers.
|
kazanGophers := []gopher{}
|
||||||
// Basically, a gophers list without ignored members.
|
nizhnyGophers := []gopher{}
|
||||||
filtered := []gopher{}
|
|
||||||
|
|
||||||
// keys is a set of all participants keys.
|
// keys is a set of all participants keys.
|
||||||
// Needed to detect collisions.
|
// Needed to detect collisions.
|
||||||
|
@ -36,14 +45,17 @@ func TestWinner(t *testing.T) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
filtered = append(filtered, g)
|
if g.nizhnyNovgorod {
|
||||||
|
nizhnyGophers = append(nizhnyGophers, g)
|
||||||
|
} else {
|
||||||
|
kazanGophers = append(kazanGophers, g)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(filtered) >= 5 {
|
t.Run("Kazan", func(t *testing.T) {
|
||||||
rand.Seed(time.Now().UTC().UnixNano())
|
runWinnerTest(t, kazanGophers)
|
||||||
winner := rand.Intn(len(filtered))
|
})
|
||||||
t.Logf("The winner is: %s!", filtered[winner].key())
|
t.Run("NizhnyNovgorod", func(t *testing.T) {
|
||||||
} else {
|
runWinnerTest(t, nizhnyGophers)
|
||||||
t.Log("Not enough participants")
|
})
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue