Skip to content

Commit d31bcaf

Browse files
feat: add JsonPatch structure and unit tests
1 parent a8da3d8 commit d31bcaf

2 files changed

Lines changed: 34 additions & 0 deletions

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package zio.schema.json
2+
3+
import zio.schema.DynamicValue
4+
5+
sealed trait JsonPatch {
6+
7+
def apply(target: DynamicValue): Either[String, DynamicValue] = {
8+
val _ = target
9+
Left("Implementation missing")
10+
}
11+
}
12+
13+
object JsonPatch {
14+
final case class Add(path: String, value: DynamicValue) extends JsonPatch
15+
final case class Remove(path: String) extends JsonPatch
16+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package zio.schema.json
2+
3+
import zio.schema.DynamicValue
4+
import zio.test._
5+
import zio.test.Assertion._
6+
7+
object JsonPatchSpec extends ZIOSpecDefault {
8+
override def spec: Spec[Any, Any] = suite("JsonPatch Spec")(
9+
test("Add operation should hold correct path and value") {
10+
val patch = JsonPatch.Add("path", DynamicValue("value"))
11+
assert(patch.path)(equalTo("path"))
12+
},
13+
test("Remove operation should hold correct path") {
14+
val patch = JsonPatch.Remove("path")
15+
assert(patch.path)(equalTo("path"))
16+
}
17+
)
18+
}

0 commit comments

Comments
 (0)