Skip to content

feat: add DeleteUser to storage interface and backends - #17

Merged
pragneshbagary merged 2 commits into
go-thin:mainfrom
WilliamK112:feat-add-delete-user
Jun 18, 2026
Merged

feat: add DeleteUser to storage interface and backends#17
pragneshbagary merged 2 commits into
go-thin:mainfrom
WilliamK112:feat-add-delete-user

Conversation

@WilliamK112

Copy link
Copy Markdown
Contributor

Summary

  • Extend storage.Storage with DeleteUser(id string) error.
  • Implement DeleteUser in both built-in backends (sqlite + postgres).
  • Add storage tests for successful user deletion.
  • Keep the simple in-memory service test storage implementation compliant with the expanded interface.
  • Update README example of custom backend contract.

Closes #12

@pragneshbagary

pragneshbagary commented Jun 17, 2026

Copy link
Copy Markdown
Member

Good work on covering both backends and the README! One thing is missing though: internal/storage/memory/memory.go also needs DeleteUser InMemoryStorage no longer satisfies the Storage interface after this change.

Could you add it?

func (s *InMemoryStorage) DeleteUser(id string) error {
	s.mu.Lock()
	defer s.mu.Unlock()
	for username, user := range s.users {
		if user.ID == id {
			delete(s.users, username)
			return nil
		}
	}
	return nil
}

The reason the build passed locally is that nothing in this branch directly assigns *InMemoryStorage to storage.Storage, so the compiler didn't catch it but it will break as soon as someone uses the memory backend (e.g. in examples or tests).

@WilliamK112

Copy link
Copy Markdown
Contributor Author

Thanks for catching that. I added \DeleteUser\ to \internal/storage/memory/memory.go\ and included a memory backend regression test with a compile-time \storage.Storage\ assertion in \internal/storage/memory/memory_test.go\.

I also ran \git diff --check\ locally. I couldn't run \go test ./...\ in this Codex environment because the Go toolchain isn't installed on PATH here.

@pragneshbagary
pragneshbagary merged commit 213b3e8 into go-thin:main Jun 18, 2026
@pragneshbagary

Copy link
Copy Markdown
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add DeleteUser to Storage interface

2 participants