Skip to content

Commit c0dbb2e

Browse files
committed
update dependencies
1 parent 797a76d commit c0dbb2e

File tree

11 files changed

+76
-63
lines changed

11 files changed

+76
-63
lines changed

.scalafmt.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version = "3.4.0"
1+
version = "3.8.3"
22
maxColumn = 130
33
runner.dialect = scala3
44
assumeStandardLibraryStripMargin = true

build.sc renamed to build.mill

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ import mill.scalalib._
33
import mill.scalalib.publish._
44

55
object Ver {
6-
val circeParser = "0.14.6"
7-
val circeYaml = "0.15.1"
6+
val circeParser = "0.14.10"
7+
val circeYaml = "0.16.0"
88
val decline = "2.4.1"
9-
val fs2 = "3.9.3"
10-
val munit = "1.0.0-M10"
9+
val fs2 = "3.11.0"
10+
val munit = "1.0.2"
1111
}
1212

13-
object sfenv extends RootModule with ScalaModule with PublishModule {
14-
def scalaVersion = "3.3.1"
13+
object `package` extends RootModule with ScalaModule with PublishModule {
14+
def scalaVersion = "3.5.1"
1515
def publishVersion = "0.1.0"
1616
def scalacOptions = Seq("-deprecation", "-Wunused:all", "-release", "11")
1717
def artifactName = "sfenv"

src/common/Sql.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,6 @@ object Sql:
7272
* Pipe that returns original Stream of Sql statements with USE ROLE inserted
7373
*/
7474
def usingRole[F[_]](secAdm: RoleName, sysAdm: RoleName): Pipe[F, Sql, Sql] = s =>
75-
import Sql.*
76-
7775
/** set current role if it is different from previous role
7876
*
7977
* @param prev

src/envr/Import.scala

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ object Import:
2525

2626
override def alter[F[_]](old: Import) =
2727
if shr.provider == old.provider && shr.share == old.share then
28-
Stream.emits(shr.roles.merge(old.roles)).collect:
29-
case (Some(n), None) => Sql.ObjGrant("DATABASE", shr.name, n, priv)
30-
case (None, Some(o)) => Sql.ObjGrant("DATABASE", shr.name, o, priv, revoke = true)
31-
else
32-
old.unCreate ++ create
28+
Stream
29+
.emits(shr.roles.merge(old.roles))
30+
.collect:
31+
case (Some(n), None) => Sql.ObjGrant("DATABASE", shr.name, n, priv)
32+
case (None, Some(o)) => Sql.ObjGrant("DATABASE", shr.name, o, priv, revoke = true)
33+
else old.unCreate ++ create

src/envr/SfEnv.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import fs2.Stream
66
import Sql.usingRole
77
import SqlOperable.given
88

9-
type ObjType = String
9+
type ObjType = String
1010

1111
case class SfEnv(
1212
secAdm: RoleName,

test/src/Database.test.scala

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,31 @@ package test
55
import fs2.*
66

77
import munit.FunSuite
8-
98
import sfenv.Main.toRbac
109

1110
class DatabaseTests extends FunSuite:
1211
import DatabaseTests.*
1312

1413
test("create"):
15-
val ddl = rule1.toRbac("DEV").map(rbac =>
16-
given SqlObj[Database] = Database.sqlObj(rbac.secAdm)
17-
rbac.databases(0).create.flatMap(_.stream(rbac.sysAdm)).toList
18-
)
14+
val ddl = rule1
15+
.toRbac("DEV")
16+
.map: rbac =>
17+
given SqlObj[Database] = Database.sqlObj(rbac.secAdm)
18+
rbac.databases(0).create.flatMap(_.stream(rbac.sysAdm)).toList
19+
1920
val expected = List(
2021
"CREATE DATABASE IF NOT EXISTS EDW_DEV DATA_RETENTION_TIME_IN_DAYS = 10 COMMENT = 'EDW core database'",
2122
"GRANT CREATE DATABASE ROLE, USAGE ON DATABASE EDW_DEV TO ROLE RL_DEV_SECADMIN"
2223
)
2324
assert(clue(ddl) == Right(expected))
2425

2526
test("drop"):
26-
val ddl = rule1.toRbac("DEV").map(rbac =>
27-
given SqlObj[Database] = Database.sqlObj(rbac.secAdm)
28-
rbac.databases(0).unCreate.flatMap(_.stream(rbac.sysAdm)).toList
29-
)
27+
val ddl = rule1
28+
.toRbac("DEV")
29+
.map: rbac =>
30+
given SqlObj[Database] = Database.sqlObj(rbac.secAdm)
31+
rbac.databases(0).unCreate.flatMap(_.stream(rbac.sysAdm)).toList
32+
3033
val expected = List("--DROP DATABASE IF EXISTS EDW_DEV")
3134
assert(clue(ddl) == Right(expected))
3235

@@ -36,8 +39,8 @@ class DatabaseTests extends FunSuite:
3639
curr <- rule2.toRbac("DEV")
3740
prev <- rule1.toRbac("DEV")
3841
yield {
39-
val currDb = curr.databases(0)
40-
val prevDb = prev.databases(0)
42+
val currDb = curr.databases(0)
43+
val prevDb = prev.databases(0)
4144
given SqlObj[Database] = Database.sqlObj(curr.secAdm)
4245
currDb.alter(prevDb).flatMap(_.stream(curr.sysAdm)).toList
4346
}

test/src/Grantables.test.scala

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
package sfenv
22
package envr
33

4-
import munit.FunSuite
54
import fs2.*
5+
66
import Grantables.*
7+
import munit.FunSuite
78

89
class GrantablesTests extends FunSuite:
9-
val of = "TABLE"
10-
val to = "DB1.SCH1"
10+
val of = "TABLE"
11+
val to = "DB1.SCH1"
1112
val grantee = RoleName.Database("DB1", "SCH1_RW")
12-
val ps = Privileges(List("SELECT", "INSERT"))
13-
val rs = Roles(List(RoleName.Database("DB1", "SCH1_R")))
14-
val envAdm = RoleName.Account("ENVADMIN")
13+
val ps = Privileges(List("SELECT", "INSERT"))
14+
val rs = Roles(List(RoleName.Database("DB1", "SCH1_R")))
15+
val envAdm = RoleName.Account("ENVADMIN")
1516

1617
def sqls(xs: Stream[Pure, Sql]) = xs.flatMap(_.stream(envAdm, true)).compile.toList
1718

test/src/ObjMeta.test.scala

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@ package sfenv
22
package envr
33
import fs2.*
44

5-
import munit.FunSuite
65
import PropVal.*
6+
import munit.FunSuite
77

88
class ObjMetaTests extends FunSuite:
99
val testProps = Map("STR_PROP" -> Str("STR_VAL"), "NUM_PROP" -> Num(2), "BOOL_PROP" -> Bool(true))
10-
val comment = Some("A sample comment")
11-
val tags = Map("tag1" -> "tag value 1", "tag2" -> "tag value 2")
12-
val sysAdm = RoleName.Account("ENVADMIN")
10+
val comment = Some("A sample comment")
11+
val tags = Map("tag1" -> "tag value 1", "tag2" -> "tag value 2")
12+
val sysAdm = RoleName.Account("ENVADMIN")
1313

1414
def sqls(xs: Stream[Pure, Sql]) = xs.flatMap(_.stream(sysAdm, true)).compile.toList
1515

1616
test("toString - props"):
17-
val testOM = ObjMeta(testProps)
17+
val testOM = ObjMeta(testProps)
1818
val expected = " STR_PROP = STR_VAL NUM_PROP = 2 BOOL_PROP = TRUE"
1919

2020
assert(clue(testOM.toString()) == expected)
@@ -31,12 +31,18 @@ class ObjMetaTests extends FunSuite:
3131
assert(clue(testOM.toString()) == expected)
3232

3333
test("alter - comment"):
34-
val oldComment = ObjMeta(comment = Some("An old comment"))
35-
val newComment = ObjMeta(comment = Some("A new comment"))
34+
val oldComment = ObjMeta(comment = Some("An old comment"))
35+
val newComment = ObjMeta(comment = Some("A new comment"))
3636
val newComment2 = ObjMeta(comment = None)
3737

38-
assert(clue(sqls(newComment.alter("SCHEMA", "DB1.SCH1", oldComment))) == List("ALTER SCHEMA IF EXISTS DB1.SCH1 SET COMMENT = 'A new comment'"))
39-
assert(clue(sqls(newComment2.alter("SCHEMA", "DB1.SCH1", oldComment))) == List("ALTER SCHEMA IF EXISTS DB1.SCH1 UNSET COMMENT"))
38+
assert(
39+
clue(sqls(newComment.alter("SCHEMA", "DB1.SCH1", oldComment))) == List(
40+
"ALTER SCHEMA IF EXISTS DB1.SCH1 SET COMMENT = 'A new comment'"
41+
)
42+
)
43+
assert(
44+
clue(sqls(newComment2.alter("SCHEMA", "DB1.SCH1", oldComment))) == List("ALTER SCHEMA IF EXISTS DB1.SCH1 UNSET COMMENT")
45+
)
4046

4147
test("alter - props"):
4248
val oldOM = ObjMeta(Map("STR_PROP" -> Str("STR_VAL"), "NUM_PROP" -> Num(3), "BOOL_PROP" -> Bool(true)))

test/src/Props.test.scala

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,29 @@
11
package sfenv
22
package envr
33

4-
import munit.FunSuite
5-
import PropVal.*
6-
import Props.propsToStrSeq
74
import cats.syntax.all.*
85

6+
import Props.propsToStrSeq
7+
import PropVal.*
8+
import munit.FunSuite
9+
910
class PropsTests extends FunSuite:
1011
test("Props - Simple"):
1112
val testProps = Map("STR_PROP" -> Str("STR_VAL"), "NUM_PROP" -> Num(2), "BOOL_PROP" -> Bool(true))
12-
val expected = "STR_PROP = STR_VAL NUM_PROP = 2 BOOL_PROP = TRUE"
13+
val expected = "STR_PROP = STR_VAL NUM_PROP = 2 BOOL_PROP = TRUE"
1314
assert(clue(testProps.propsToStrSeq.mkString_(" ")) == expected)
1415

1516
test("Props - LC"):
1617
val testProps = Map("str_prop" -> Str("str_val"), "num_prop" -> Num(2), "bool_prop" -> Bool(true))
17-
val expected = "STR_PROP = str_val NUM_PROP = 2 BOOL_PROP = TRUE"
18+
val expected = "STR_PROP = str_val NUM_PROP = 2 BOOL_PROP = TRUE"
1819
assert(clue(testProps.propsToStrSeq.mkString_(" ")) == expected)
1920

2021
test("Props - spaces in string"):
2122
val testProps = Map("STR_PROP" -> Str("value with spaces"))
22-
val expected = "STR_PROP = 'value with spaces'"
23+
val expected = "STR_PROP = 'value with spaces'"
2324
assert(clue(testProps.propsToStrSeq.mkString_(" ")) == expected)
2425

2526
test("Props - non-alpha string"):
2627
val testProps = Map("SIZE" -> Str("2XLARGE"))
27-
val expected = "SIZE = '2XLARGE'"
28+
val expected = "SIZE = '2XLARGE'"
2829
assert(clue(testProps.propsToStrSeq.mkString_(" ")) == expected)

test/src/Schema.test.scala

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ class SchemaTests extends FunSuite:
1111
import SchemaTests.*
1212

1313
test("create"):
14-
val ddl = rule1.toRbac("DEV").map(rbac =>
15-
val db = rbac.databases(0)
16-
given SqlObj[Schema] = Schema.sqlObj(db.name)
17-
db.schemas(0).create.flatMap(_.stream(rbac.sysAdm)).toList
18-
)
14+
val ddl = rule1
15+
.toRbac("DEV")
16+
.map: rbac =>
17+
val db = rbac.databases(0)
18+
given SqlObj[Schema] = Schema.sqlObj(db.name)
19+
db.schemas(0).create.flatMap(_.stream(rbac.sysAdm)).toList
20+
1921
val expected = List(
2022
"CREATE SCHEMA IF NOT EXISTS EDW_DEV.CUSTOMER WITH MANAGED ACCESS DATA_RETENTION_TIME_IN_DAYS = 10",
2123
"CREATE DATABASE ROLE IF NOT EXISTS EDW_DEV.CUSTOMER_R",
@@ -34,11 +36,13 @@ class SchemaTests extends FunSuite:
3436
assert(clue(ddl) == Right(expected))
3537

3638
test("drop"):
37-
val ddl = rule1.toRbac("DEV").map(rbac =>
38-
val db = rbac.databases(0)
39-
given SqlObj[Schema] = Schema.sqlObj(db.name)
40-
db.schemas(0).unCreate.flatMap(_.stream(rbac.sysAdm)).toList
41-
)
39+
val ddl = rule1
40+
.toRbac("DEV")
41+
.map: rbac =>
42+
val db = rbac.databases(0)
43+
given SqlObj[Schema] = Schema.sqlObj(db.name)
44+
db.schemas(0).unCreate.flatMap(_.stream(rbac.sysAdm)).toList
45+
4246
val expected = List(
4347
"DROP DATABASE ROLE IF EXISTS EDW_DEV.CUSTOMER_R",
4448
"DROP DATABASE ROLE IF EXISTS EDW_DEV.CUSTOMER_RW",
@@ -53,9 +57,9 @@ class SchemaTests extends FunSuite:
5357
curr <- rule2.toRbac("DEV")
5458
prev <- rule1.toRbac("DEV")
5559
yield {
56-
val db = curr.databases(0)
57-
val currSch = curr.databases(0).schemas(0)
58-
val prevSch = prev.databases(0).schemas(0)
60+
val db = curr.databases(0)
61+
val currSch = curr.databases(0).schemas(0)
62+
val prevSch = prev.databases(0).schemas(0)
5963
given SqlObj[Schema] = Schema.sqlObj(db.name)
6064
currSch.alter(prevSch).flatMap(_.stream(curr.sysAdm)).toList
6165
}

test/src/SfEnv.test.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ package test
55
import fs2.*
66

77
import munit.FunSuite
8-
98
import sfenv.Main.toRbac
109

1110
class RbacTests extends FunSuite:
@@ -20,7 +19,7 @@ class RbacTests extends FunSuite:
2019
assert(clue(ddl) == Right(expected))
2120

2221
test("drop"):
23-
val ddl = rule1.toRbac("DEV").map(x => x.unCreate.flatMap(_.stream(x.sysAdm)).toList)
22+
val ddl = rule1.toRbac("DEV").map(x => x.unCreate.flatMap(_.stream(x.sysAdm)).toList)
2423
val expected = List("--DROP DATABASE IF EXISTS EDW_DEV")
2524
assert(clue(ddl) == Right(expected))
2625

0 commit comments

Comments
 (0)